JSON to TypeScript

Generate TypeScript interfaces from a JSON sample.

Your JSON is parsed and converted entirely in your browser, so it stays on your device and nothing is uploaded to a server.

Need Go, Rust or Python types? Try JSON to Code.

About JSON to TypeScript

This json to typescript converter turns a sample JSON object or array into ready-to-use TypeScript interfaces in seconds. Paste a real API response and it infers field types, nests child objects into their own named interfaces, merges arrays of objects into one shape, and marks keys missing from some items as optional with a question mark. It is built for frontend and backend developers, QA engineers, and anyone wiring up typed clients who would rather generate typescript types from json than hand-write them. Use it as a quick typescript interface generator while exploring an unfamiliar endpoint, or to keep your models in sync with sample payloads. Everything runs locally in your browser, so the JSON you paste is processed on your device and nothing is uploaded to a server.

Features

How to use the JSON to TypeScript

  1. Paste your JSON object or array into the input box.
  2. Set the Root interface name to match your model, or leave it as Root.
  3. Review the generated TypeScript interfaces in the output panel.
  4. Copy the result or download it as a .ts file.

Example

Input

{ "id": 1, "name": "Ada", "tags": ["a", "b"] }

Output

export interface Root {
  id: number;
  name: string;
  tags: string[];
}

A flat JSON object becomes a single typed interface.

Common errors & troubleshooting

Frequently asked questions

What is the JSON to TypeScript converter?
It is a tool that reads a sample JSON object or array and generates matching TypeScript interfaces, inferring each field's type so you can drop the result straight into your codebase.
How do I convert JSON to TypeScript interfaces?
Paste your JSON into the input box, optionally set the Root interface name, then copy or download the generated interfaces from the output panel.
How does JSON to TypeScript handle arrays of objects?
It merges keys across every element into one interface. Any key missing from some elements is marked optional with a question mark so the type covers the whole array.
How are nested objects converted to TypeScript?
Each nested object becomes its own exported interface with a PascalCase name, and the parent references it by type rather than inlining the shape.
What happens with null or mixed-type values?
Null values produce a union with null, and fields that hold more than one primitive type become a union such as string | number.
Is my JSON sent anywhere when I convert it to TypeScript?
No. The JSON to TypeScript conversion runs entirely in your browser, so the data you paste is processed locally and never leaves your device.

Related tools

All ArrayKit tools