JSON to TypeScript

Generate TypeScript interfaces from JSON.

About the JSON to TypeScript

Paste a JSON payload — an API response, a fixture, a config file — and get TypeScript interfaces describing its shape. Nested objects are pulled out into their own named interfaces rather than inlined, and every type is inferred from the values in your sample. Generation runs on quicktype inside your browser, so a response containing real customer data never leaves the tab.

How to use the JSON to TypeScript

  1. Paste your JSON into the input panel, or press Sample to load an example.
  2. Set Root name to whatever the top-level interface should be called.
  3. Press Generate to produce the interfaces.
  4. Copy the result, or Download it as types.ts.

Frequently asked questions

How are the interfaces named?
The top-level one takes whatever you put in Root name. Nested objects are named after the key holding them, so a "profile" object becomes an interface called Profile.
Does this give me runtime validation?
No. TypeScript interfaces are erased at compile time, so nothing checks that a real response matches. Pair them with a runtime validator such as Zod, or validate the payload against a JSON Schema, when the data comes from outside your codebase.
How are null and optional fields handled?
Only from what your sample shows. A field that is null in the sample is typed null, and a field absent from the sample does not appear at all. Paste a payload that exercises the optional fields, or widen the types by hand afterwards.
What if my JSON is a top-level array?
You get one interface describing a single element, named from Root name, rather than a wrapper around the array. Declare the array as Root[] where you use it.
Is my JSON uploaded anywhere?
No. quicktype runs as JavaScript in the page, so the payload stays in your browser and there is no server that could log it.

Related tools