Convert JSON to TypeScript interfaces
Typing an API response by hand is slow and easy to get wrong, especially when it is several levels deep. Paste a real JSON sample above and the converter walks the whole structure, creating one interface per nested object and naming it after its key — profile becomes Profile, an array called posts becomes Post[].
How the types are inferred
- Primitives map to
string,number,booleanandnull. - Objects become their own interface.
- Arrays of objects are merged into one interface; keys missing from some items become optional.
- Mixed arrays become unions, for example
(string | number)[]. Empty arrays becomeunknown[].
Tips for accurate types
The output can only be as complete as the sample. Paste a response that includes optional fields and at least one item for every array, and replace null-only fields with a real value where you know it. For contracts you publish to others, generate types from an OpenAPI or JSON Schema definition instead of from examples.
Frequently asked questions
How are arrays of objects handled?
All objects in the array are merged into one interface. A key that appears in some objects but not others becomes optional (key?: type), and a key whose values differ in type becomes a union such as string | number.
What happens with null values?
A field that is null in the sample is typed as null; if other samples in the same array have a real value, you get a union like string | null. Paste a sample with real values where you can — one example can't tell the tool what a null field normally holds.
Is my JSON sent to a server?
No. Parsing and conversion run in your browser, so it is safe to paste API responses that contain private data.
Interface or type alias?
The output uses interface, which is the common choice for object shapes and can be extended or merged later. You can rename interface X to type X = without other changes if your codebase prefers type aliases.
Built and maintained by Pradeep Bhandari, Senior Engineering Manager & Full-Stack Architect. Last reviewed .