JSON to TypeScript
Paste JSON and get clean TypeScript interfaces: nested objects, arrays, deduplicated shapes and a custom root name. Runs entirely in your browser.
Why generate types from JSON
When an API returns a payload, someone has to describe it in TypeScript by hand — field by field, level by level. It is slow, and the second version of the endpoint makes it stale. This tool reads the JSON once and writes the interfaces for you: every nested object becomes an interface, arrays become typed lists, and identical shapes are deduplicated automatically.
What it does
- Interfaces for every nested object, with correct field names — quoted where necessary.
- Typed arrays, including unions when an array mixes shapes.
- Deduplication: objects with the same shape reuse one interface, and a custom root name.
How to use
- Paste your JSON (an API response, a config, anything valid).
- Set the root interface name if you dislike the default.
- Copy the generated TypeScript into your project.
How it works
The generator walks the parsed JSON recursively, infers a type per value, names object interfaces after their key in PascalCase and remembers each shape’s signature so identical objects reuse a single interface. Everything runs locally in your browser.
Frequently asked questions
How are field names handled?
Interface names are converted to PascalCase, and keys that are not valid TypeScript identifiers are preserved but quoted — exactly how the language expects them.
What happens with empty arrays or nulls?
An empty array becomes unknown[] (there is nothing to infer from), null becomes the null type, and mixed arrays produce a union of the types found inside.
Related tools
JSON Formatter & Validator
Format, beautify, validate, and minify JSON data with tree view
XML Formatter & Beautifier
Format, beautify, minify, and validate XML documents
CSV to JSON Converter
Convert CSV data to JSON array format with customizable delimiters
JSON to CSV Converter
Convert JSON array data to CSV format with auto-detected columns
JSON to YAML Converter
Convert JSON data to YAML format with proper indentation
YAML to JSON Converter
Convert YAML data to JSON format with support for nested structures