JSON to TypeScript
Generate TypeScript interfaces from a sample JSON object.
Designed to run in your browser. See the privacy policy.
About JSON to TypeScript
This JSON to TypeScript converter reads a sample JSON document and writes matching TypeScript interfaces for it. Paste an API response, a config file or a fixture and you get a starting set of types to drop into your project instead of typing every field by hand.
The top-level object becomes an interface called Root. Each nested object gets its own interface named after its key in PascalCase, so a "shipping_address" field produces a ShippingAddress interface, and arrays of objects produce a name ending in Item, such as LineItemsItem. Nested interfaces are listed first and Root comes last. The conversion runs in your browser as you type, so it is handy for payloads you would rather keep on your own machine.
How to use
- Paste a JSON object or array into the JSON input box.
- Read the generated code in the TypeScript interfaces panel; it updates on every keystroke.
- If the JSON is malformed, fix the problem shown in the error message and the output reappears.
- Click copy to put the interfaces on your clipboard, or download to save them as types.ts.
- Review the result and refine it by hand where your real data varies from the sample.