Generate TypeScript interfaces from a JSON sample, with nested types, arrays and optional fields. Runs in your browser.
How to use the JSON to TS
Paste a JSON object or array.
Optionally set the root interface name.
Copy the generated TypeScript interfaces.
This is a JSON to TypeScript generator that infers a set of interfaces from an example JSON object or array, so you can paste an API response and get ready-to-use types instead of writing them by hand.
It is a big time-saver when you are consuming an API or a config file: paste a response, optionally name the root interface, and copy clean TypeScript straight into your code.
Generation runs entirely in your browser, so your data never leaves your device, which matters when the sample contains real values.
It handles real-world shapes: nested objects become their own named interfaces referenced from the parent, arrays of objects are merged into one interface, and union types are produced where values vary.
When the objects in an array do not all have the same keys, the keys missing from some elements are marked optional with a question mark, which matches how the data actually behaves and keeps the types honest.
One important point: it infers a shape from the single sample you give it, rather than enforcing a schema. If a field is sometimes null or absent in real data but not in your sample, the generated type will not know that, so use a representative example.
Frequently asked questions
Each nested object becomes its own named interface, referenced from its parent, so the result is clean and reusable.
Arrays of objects are merged into one interface, and keys missing from some elements are marked optional. Arrays of mixed primitives become a union element type.
No. The types are generated entirely in your browser, so your data never leaves your device.
It infers the shape from the sample you paste, it does not validate against a schema. Use a representative example so optional or nullable fields are captured.
string, number, boolean and null primitives, nested interfaces for objects, typed arrays, optional properties for keys that are not always present, and unions for mixed values.
Embed this tool
Add this tool to your own website. Copy the snippet below; it stays up to date automatically.
<iframe src="https://monu.tools/embed/en/json-to-typescript" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>Learn more
Turn a JSON Response into a TypeScript Interface in Seconds
Generate a TypeScript interface from any JSON response: optional fields, nullables, nested types, and where a single sample falls short.
Why Is My JSON Invalid? How to Find and Fix the Error
The six mistakes that break JSON, how to read a parser error, and how to fix invalid JSON fast.
How to Minify JSON to Shrink API Payloads
What minifying JSON actually removes, the realistic 20 to 40 percent size win, and why server compression usually matters more.
How to Convert JSON to CSV (and Keep Nested Data Sane)
Convert JSON to CSV without losing your nested objects: flattening, exploding arrays, delimiters, Excel BOM gotchas, and the round-trip back.
YAML vs JSON: Which One Should Your Config Use?
YAML vs JSON compared for config files and APIs: syntax, comments, the Norway problem, indentation traps, TOML, and lossless conversion.
Related tools
Format, beautify and validate JSON online with clear error messages for invalid input.
Minify and validate JSON in your browser, and see how many bytes you save.
Convert JSON to CSV and CSV back to JSON, both ways. Choose the delimiter, handle quoted fields, and copy the result. Everything runs in your browser.
Convert YAML to JSON and JSON back to YAML, both ways. Validates as it converts and shows clear errors. Everything runs in your browser.