JSON to TypeScript
Convert JSON data to TypeScript interfaces and types. Generate type-safe code from API responses automatically.
Data workspace
Infer TypeScript interfaces or type aliases from JSON samples, including nested objects and mixed arrays.
Method and limits
The root name identifies the generated declaration. Object samples contribute every own key; a property missing from some array objects becomes optional. Distinct observed types form unions. Names for nested declarations are made valid and unique; unusual property keys are quoted.
Inference describes the samples, not a complete API contract or runtime validator. Empty arrays use any[]. Null stays null. The optional switch marks every property optional; readonly restricts TypeScript assignment, not runtime mutation. JSON numbers use JavaScript precision.
These transformations run in your browser. The tool does not submit the editor contents to a conversion service. This describes the tool operation, not the site's advertising or account policies.
Try this example
{"id":1,"name":"A"} produces an exported Root interface with number and string fields. [1,2] produces export type Root = number[]. [{"a":1},{"b":true}] keeps both keys as optional fields.
Copied
Copy failed. Select the result and copy it manually.
About JSON to TypeScript
Infer TypeScript interfaces or type aliases from JSON samples, including nested objects and mixed arrays.
{"id":1,"name":"A"} produces an exported Root interface with number and string fields. [1,2] produces export type Root = number[]. [{"a":1},{"b":true}] keeps both keys as optional fields.
Inference describes the samples, not a complete API contract or runtime validator. Empty arrays use any[]. Null stays null. The optional switch marks every property optional; readonly restricts TypeScript assignment, not runtime mutation. JSON numbers use JavaScript precision.
Use Cases
How to use
Paste representative JSON, set a valid root name and choose interface or type, optional, readonly and export options. Check the inferred union and optional fields before copying into your project.
Pro Tips
- When object samples in an array have different keys, a key missing from one sample is optional. No observed field is silently removed.
- No. TypeScript declarations describe static types and do not execute checks. Review the inferred shape and use a runtime validator separately when needed.
Frequently Asked Questions
When object samples in an array have different keys, a key missing from one sample is optional. No observed field is silently removed.
No. TypeScript declarations describe static types and do not execute checks. Review the inferred shape and use a runtime validator separately when needed.