JSON to TypeScript interfaces
About JSON to TypeScript
Convert JSON to TypeScript interfaces by pasting a sample document. The tool reads the shape of your data and writes typed interfaces you can drop into your code for autocomplete and compile-time checks.
Each nested object gets its own named interface, and arrays of objects get optional-property detection. It is the quickest JSON to TS step when you consume an API without published types.
Runs in your browser. Nothing is uploaded.
How it works
Nested interfaces
Each nested object becomes its own named interface, and the parent refers to it by name. Array element types are named from the singular of the key, so a users array gives a User interface.
Optional-property detection
When the input has an array of objects with different keys, Optional detection marks keys missing from some elements with ?. This matches list data where some fields only sometimes appear.
The export keyword
Toggle whether interfaces start with export. Turn it on to paste them into a module other files import. Turn it off for a local snippet.
Type inference and its limits
Types come from the sample values: string, number, boolean, arrays and nested objects. One example cannot show every case. An empty array becomes unknown[] and a null value becomes null, so refine those by hand.
Frequently asked questions
How does it decide which properties are optional?
With optional detection on, any key missing from at least one object in an array gets ?. A single object gives no evidence of optional keys, so all its keys are required.
Why did a field come out as unknown[] or null?
The sample did not carry enough information. An empty array cannot show its element type, and a null value cannot show the real type. Use a fuller example or edit the type by hand.
Can it convert a JSON Schema to TypeScript?
No. This tool infers types from sample data. If you paste a JSON Schema, you get types that describe the schema document itself. Use a schema compiler such as json-schema-to-typescript for that job.
Can I paste production API responses safely?
Yes. Generation runs in your browser and the payload is never uploaded.
Should I turn on the export keyword?
Turn it on if other files will import the interfaces. Leave it off for a local or throwaway snippet.
Does it name the nested interfaces sensibly?
Yes. Nested interfaces are named after their property names in PascalCase, and array element types use the singular form.
Learn more
Sources & last verified
We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced.
Found a wrong result or an outdated claim? Report an error and we will check it again.