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

Type mapping rules

JSON valueTypeScript type
42, 3.14number
"hello"string
true / falseboolean
nullnull
[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.