JSON to TypeScript
Generate TypeScript interfaces from JSON data.
How to Use
- Paste your JSON into the input panel. The tool accepts both objects and arrays — for arrays, the first element is used to infer the interface shape.
- A TypeScript interface is generated automatically as you type. Nested objects become inline types; arrays become typed arrays such as string[] or number[].
- Copy the generated interface code and paste it into your TypeScript project. Rename Root to match your actual type name.
Frequently Asked Questions
- How are null values handled?
- JSON null maps to the TypeScript type null. If a field may also hold a string or number in practice, you should manually update the type to string
- What happens with mixed-type arrays?
- The tool infers the type from the first array element. Arrays with mixed types (e.g. [1, "two", true]) will be typed based on that first element only. Review and add union types manually if needed.
- Are nested objects generated as separate interfaces?
- Currently, nested objects are inlined as anonymous types within the Root interface. If your project requires separate named interfaces, extract them manually after copying the generated code.