json→ts

JSON to TypeScript

Paste a JSON sample and get interfaces back — optional fields, unions, and nested types included.

By opening this website or using its tools, you agree to our Terms and Privacy Policy.

Declare as
Arrays

Explain this shape in English

Optional. Uses your browser's own on-device model — the interfaces above need no model at all.

Checking what this browser can run…

Network activity during processing
0 bytes uploaded

Your file never leaves your browser during processing

How it works

To convert JSON to a TypeScript interface, paste the JSON above and the interfaces are generated as you type: field types come straight from the data, a key missing from some records becomes optional, and repeated shapes share one named interface. It runs entirely in your browser, so nothing is uploaded.

The shape of a JSON document is its type, so this needs no cleverness and no server — the sample is parsed and walked, and each value becomes the TypeScript type it already is. Nested objects are pulled out into their own named interfaces rather than inlined, and two objects with an identical shape share one interface instead of producing a duplicate for every element of a list.

Three things are genuinely inferred rather than read off. A key present in some records and missing from others becomes optional, which is why pasting a whole API response gives a better type than pasting one record — with a single sample there is nothing to compare against and no field can be found optional. A field that holds different types across records becomes a union such as string | number, rather than being widened to any, because the union is what the data actually says. And an empty array carries no information at all, so it is typed unknown[] and reported instead of being quietly typed any[].

Some guesses are deliberately not made. A string that looks like a date stays a string: after JSON.parse it is a string, and emitting Date would produce code that does not compile against the data it came from. Integers and floats are both number, because TypeScript has no separate integer type. Everything happens in the page — the JSON never leaves your browser, which matters when the sample is a real API response with real data in it.

FAQ

Why are some fields marked optional?

Because the key was present in some records of your sample and missing from others. Optionality can only be inferred by comparing records, so a sample with one record will never produce an optional field — paste more of the response for a more accurate type.

Why is a field typed as a union like string | number?

Because the sample held both types in that position. Widening it to any would discard the only information available; the union is a faithful description of the data you pasted.

Why are date strings typed as string rather than Date?

Because that is what they are after JSON.parse. JSON has no date type, so a value like "2026-08-29" arrives as a string, and typing it as Date would produce code that does not type-check against its own input.

Is my JSON uploaded anywhere?

No. The inference runs in your browser as you type, and the live network counter below the tool shows zero bytes sent during processing.

What does the "explain in English" panel do?

It describes the generated interfaces in prose using a language model your browser provides on-device, where one exists. It is optional — the interfaces themselves are produced by a plain algorithm that works in every browser.

Related tools