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
- Generates named TypeScript interfaces from any JSON object or array
- Turns nested objects into their own exported interfaces with PascalCase names
- Merges arrays of objects into a single interface covering every key
- Marks keys missing from some elements as optional with a question mark
- Infers primitive, array, union, and null types from your sample values
- Lets you rename the root interface to match your model
- Validates the JSON and pinpoints the line and column of syntax errors
- Copy the result or download it as a .ts file
How to use the JSON to TypeScript
- Paste your JSON object or array into the input box.
- Set the Root interface name to match your model, or leave it as Root.
- Review the generated TypeScript interfaces in the output panel.
- 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
- The output shows an Invalid error with a line and column. — The JSON has a syntax issue such as a trailing comma, single quotes, or an unquoted key. Fix it at the reported line and column, then the interfaces regenerate.
- A field you expected is marked optional with a question mark. — That key is absent from at least one element in your array sample. Include it in every element if it should always be required.
- A property comes out as the unknown type. — Every sample value for that key was null or undefined, so no concrete type could be inferred. Provide a sample with a real value for that field.
- Pasting a bare value like a number or string only yields a type alias. — That is expected. Wrap the value in an object or array if you want a named interface instead of a single export type alias.
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
- JSON to Code — Generate Go, Rust, Python, Java, Kotlin, C# and TypeScript types from JSON.
- JSON Formatter — Beautify, minify and validate JSON with error locations.
- JSON to CSV — Convert an array of flat JSON objects to CSV.
- JSON Viewer — Text + collapsible tree viewer with expand/collapse and node paths.
- JSON Tree Viewer — Explore JSON as a collapsible, typed tree.
- YAML ↔ JSON — Convert YAML to JSON and back.
- Mock Data Generator — Generate fake JSON data — names, emails, UUIDs, dates and more.
All ArrayKit tools