Convert JSON to TypeScript interfaces
Paste a JSON sample, such as an API response, and get TypeScript interfaces as you type. Every item in an array is inspected, so optional and nullable fields come out right.
How to use the JSON to TypeScript converter
- Paste JSON or drop a .json file on the editor.
- TypeScript interfaces appear on the right straight away.
- Set the name of the top-level type, for example Order or User.
- Copy the code, or download it as types.ts.
What you get
- One interface per nested object, named after its key
- Keys missing from some array items marked optional (?)
- Values that are sometimes null typed as T | null
- Keys that are not valid identifiers quoted
About the JSON to TypeScript converter
Built from every sample
Many converters look only at the first item of an array. This one merges all items, so a field that appears in only some of them is optional, and a number that is sometimes 1 and sometimes 1.5 is simply number.
Private by design
The conversion runs in your browser. API responses with customer data or tokens never leave your device.
Frequently asked questions
- Does it generate types or interfaces?
- Interfaces for objects, plus a type alias when the top level is an array or a plain value.
- How are array item types named?
- After their key in singular form: items becomes Item, categories becomes Category. Duplicates get a number.
- Can I get a runtime validator too?
- Yes. Switch to the Zod tab for a schema that validates data at runtime and infers the same TypeScript type.