Tools

JSON to TypeScript

Paste a JSON payload (an API response, a config file, a fixture) and get typed TypeScript interfaces back instantly. Nested objects become named sub-interfaces, arrays have their element shapes merged, and nulls and mixed types turn into unions. Everything runs in your browser; your JSON is never uploaded.

TypeScript output
Your generated interfaces will appear here.

Everything runs locally in your browser, so your JSON is never uploaded or stored.

Turn JSON into typed interfaces

Hand-writing TypeScript interfaces for every API response is tedious and error-prone: one missed optional field and the compiler stops protecting you. This converter reads the structure of real JSON and infers the types for you: primitives map to string, number, and boolean; objects become interfaces; and arrays are typed by their element shape.

When an array holds objects with slightly different shapes, the tool merges them into a single interface. Fields that are missing from some elements are marked optional, and values that vary in type across the data are combined into a union. A null adds | null, and an empty array becomes unknown[] so you can decide the intended type yourself. Copy the result or download it as a .ts file and drop it straight into your project.

Frequently asked questions

How does it handle nested objects?
Each nested object becomes its own named sub-interface, with the name derived from the property key (PascalCased). The parent interface then references that type by name, so you get clean, reusable definitions instead of one deeply inlined blob.
What happens with arrays of objects?
The converter samples the array elements and merges their shapes into a single element interface. Keys that appear in only some elements are marked optional with a "?", and differing value types are combined into a union. An empty array becomes unknown[], since there is nothing to infer from.
How are null values and mixed types represented?
A null value adds "| null" to the inferred type. When a field or array holds more than one primitive type across the data, those types are emitted as a union (for example, string | number). unknown is used only when no concrete type can be inferred.
Can I rename the root interface?
Yes. Set the root interface name in the field above the editor. Nested interface names are generated from their keys, and array element names are singularized (for example, a "users" array yields a "User" interface).
Is my JSON sent anywhere?
No. Parsing and type generation run entirely in your browser using standard Web APIs. There are no network calls, no uploads, and nothing is stored. You can even use it offline once the page has loaded.
Is there a size limit?
Inputs are capped at about 5 MB to keep the browser responsive, and very large arrays are sampled for shape inference. For typical API responses and fixtures this is more than enough.