JSON to TypeScript

Generate TypeScript interfaces from any JSON object instantly in your browser.

JSON Input
TypeScript Output

About JSON to TypeScript

This tool analyses a JSON value and generates TypeScript interface declarations with accurate types. Nested objects produce additional named interfaces. Arrays are typed as T[] where T is inferred from the first element.

Type inference rules

stringstring   numbernumber   booleanboolean

null / undefinednull (or unknown with the optional flag)

object → named interface (child interfaces are appended below)

array of objectsChildType[] with a separate interface generated

array of primitivesstring[] / number[] / etc.

mixed array(string | number | ...)[]

empty arrayunknown[]

Frequently asked questions

Can I use this with API responses?
Yes. Paste the JSON body from any REST API call and get ready-to-use interfaces. If some fields are nullable in the real API, enable the "optional when null" option to mark those fields as ?: type | null.
How are property names handled?
Property names are used as-is. If a key contains special characters or is a reserved word, it will be wrapped in quotes in the interface definition.
What about deeply nested JSON?
Nested objects are recursively converted to separate interfaces. Interface names are derived from the parent property name with the first letter capitalised (e.g. address becomes Address).

Related tools