UTILS.
Private by default
TS

JSON to TypeScript

Generate TypeScript interfaces from a JSON sample, inferring types recursively.

Your files stay on this device

Files are processed in your browser, never uploaded. The site downloads code and assets to run the tools. No accounts or trackers.

Use Download to save this tool as one HTML file for offline use.

Privacy →
output

Try a worked example

Example

Paste [{"id":1},{"id":2,"note":"late"}]. The result is type Root = RootItem[]; and an interface RootItem with id: number and note?: string, because note is missing from the first item.

Keep in mind

Types come only from the sample you paste. A field that is a string here may be null in other responses, and numbers are not split into integers and decimals, so check the result against the API documentation.

About this tool

Paste a JSON sample, such as an API response, and get matching TypeScript interfaces, generated entirely in your browser. Every item in an array is inspected: fields missing from some items become optional, and values of different types become unions.

Frequently asked questions

How are nested objects handled?
Each nested object becomes its own interface, named in PascalCase after its key. Objects inside arrays get an Item suffix, such as TagsItem.
How are arrays typed?
Every element is inspected. Objects merge into one interface, fields absent from some of them are marked optional with ?, and mixed values become a union such as (string | number)[]. Empty arrays become unknown[].

More tools