JSON to TypeScript
Paste JSON or open a .json file and get TypeScript interfaces or types, with optional keys and unions.
The JSON you enter never leaves this device.
How to use it
- 1
Paste JSON or open a file
Paste JSON into the box, or open a .json file of up to 5 MB. The file is read in this browser and is not uploaded.
- 2
Pick the output form
Choose interface or type, and type a name for the top type. An empty name uses Root. Other names are taken from the keys.
- 3
Read the types
Objects in an array are merged into one type, and a key missing from some of them becomes optional with a question mark. A value that is sometimes null becomes a union with null, and an empty array becomes unknown[].
- 4
Copy the result
Press Copy result. The types come from one sample, so other data with the same shape may need a wider type. Nothing leaves this browser.