JSON to TypeScript 🔒 Runs locally in your browser — nothing is uploaded.

Generate TypeScript interfaces from a JSON sample.

 

About this tool

Typing out TypeScript interfaces to match an API response is busywork — and easy to get subtly wrong. Paste a sample JSON payload here and get matching interfaces instantly. Nested objects are extracted into their own named interfaces, arrays of objects are merged so that keys missing from some entries become optional, and values with more than one type become unions.

It runs entirely in your browser using a lightweight inferer — your JSON is never uploaded. Paste, tweak the root name if you like, and copy ready-to-use types into your project.

Frequently asked questions

Is my JSON data uploaded anywhere?

No. Parsing and type inference run entirely in your browser's JavaScript — your JSON never leaves your device.

How does it handle an array where objects have different fields?

It merges the keys from every object in the array into one interface; any key that isn't present in all of them is marked optional with a `?` instead of being dropped.

What happens with an array of mixed types, like numbers and strings?

It produces a union array type such as `(string | number)[]`, so the shape still reflects every value actually seen in the sample.

Can I generate type aliases instead of interfaces?

Yes, toggle 'as type' to switch every generated `interface Name {}` into `type Name = {}` — useful if your codebase prefers type aliases.

What happens if I paste invalid JSON?

The tool shows an error message with the exact line and column of the problem and lets you jump straight to it, instead of a generic 'invalid JSON' message.

Does it handle nested objects and arrays, not just flat JSON?

Yes. A nested object becomes its own named interface, auto-named from the parent key (so `profile: {...}` produces a `Profile` interface), and array names are singularized (`roles` → `Role[]`). An array of objects generates one interface shared by every element, with `?` on fields not present everywhere — not a separate interface per item.