JSON to TypeScript Interface
Convert JSON data into clean TypeScript interfaces. Includes nested types, optional fields, arrays, and union types. Runs entirely in your browser.
Input JSON
How it works
- Paste any valid JSON on the left.
- Click Convert to TypeScript — the interface appears instantly.
- All types are inferred from the JSON values: numbers, strings, booleans, arrays, objects, and
null. - Click Make all optional to prefix every field with
?.
Type mapping rules
| JSON value | TypeScript type |
|---|---|
42, 3.14 | number |
"hello" | string |
true / false | boolean |
null | null |
[1, 2, 3] | number[] |
[{...}, {...}] (array of objects) | NestedType[] |
{"a": 1} | NestedObject { a: number } |
About JSON to TypeScript Interface
Generating TypeScript interfaces from JSON turns raw data samples into compile-time-checked type definitions. It is especially useful when consuming third-party APIs, database records, or LLM responses where you know the shape of the data but do not want to type it out by hand. This tool infers interfaces, nested types, arrays, and unions directly from the JSON you paste.
Use it whenever you need a quick, accurate type for a JSON payload, or as a starting point that you then refine. Keep in mind that inferred types reflect only what the sample shows: fields absent from the sample are missing from the interface, null values become optional fields, and heterogeneous arrays become union types — so inspect the output and add optional fields or generics where your real data varies.