Convert JSON to TypeScript interfaces, type aliases, classes or Zod schemas
A free JSON to TypeScript converter: paste JSON and get types back instantly. Choose an interface, a type alias, a class with fromJSON and toJSON, or a Zod schema with its inferred type. Property types are inferred from the data, nested objects become their own types, and keys that can be null or missing become optional properties typed T | null. Interfaces, aliases and Zod schemas keep the JSON keys exactly as they are, so they describe what JSON.parse returns. Conversion runs entirely in your browser, so your JSON is never uploaded to a server.
Output formats: Interface (export interface with the JSON keys as properties), Type alias (export type with an object literal type), Class (Class with fromJSON and toJSON), Zod (Zod schema plus the inferred type).
| Option | What it does |
|---|---|
| Root Type Name | Names the top-level Type. |
| Field Naming Convention | One of camelCase, PascalCase, snake_case, Preserve Original. Defaults to camelCase. Only available with the Class format. |
| Type for null values | Either unknown or string, used when a key is null in every sample. |
| Separate Classes | Write each type to its own .ts file, importing the types it refers to. Off (the default) puts every type in one file, so Copy All pastes into a single file that compiles. |
| Map original JSON keys | Read and write each property under the original JSON key in fromJSON and toJSON. Without it a property only binds to a key spelled exactly like it, so a snake_case key is not read into a camelCase property. Only available with the Class format. |
| JSON value | TypeScript type |
|---|---|
| string | string |
| integer or decimal | number |
| true / false | boolean |
| ISO-8601 timestamp | string |
| array | T[] |
| object | nested type |
| null or missing in some samples | optional property, T | null |
| null | unknown (configurable) |
{
"id": 12345,
"product_name": "Wireless Mouse",
"price": 24.99,
"in_stock": true,
"tags": ["electronics", "accessories"],
"manufacturer": {
"name": "Acme Corp",
"country": "US"
}
}
export interface Product {
id: number;
product_name: string;
price: number;
in_stock: boolean;
tags: string[];
manufacturer: Manufacturer;
}
Paste your JSON into the input pane and the TypeScript types appear beside it immediately. Set the root type name, pick Interface, Type alias, Class or Zod, then copy the code or download it. Nested JSON objects become their own types and arrays become T[]. Cast the result of JSON.parse to the root type, or run it through the Zod schema to check it.
Interfaces and type aliases cost nothing at runtime: they only describe the shape JSON.parse returns, so they keep the JSON keys exactly as written. A class gives you fromJSON and toJSON, real instances and your own property names. A Zod schema also validates the data at runtime and infers the TypeScript type from itself, so the schema and the type cannot drift apart. Zod needs the zod package; the other three need nothing.
An interface, type alias or Zod schema describes the object JSON.parse returns, and that object has the original keys. Renaming a property would make the type lie about the data. The Class format is the one that maps keys to your own naming, with fromJSON and toJSON doing the translation.
A key that is null in a sample is typed T | null; a key that is missing from some objects is optional (the ? after the name). A key that can be either gets both. The class format keeps the two apart when it writes JSON back, so a missing key stays missing and a null stays null.
JSON.parse never produces a Date: a timestamp is a string until you convert it. Typing it Date would be wrong the moment the value is read. Convert it where you need a Date.
No. Parsing, type inference, and code generation all run in your browser using JavaScript. Your JSON is never sent to a remote server, and there is no account to create. The page keeps your last input and settings in your own browser (localStorage) so they survive a reload; nothing is stored anywhere else.
The conversion itself never transmits your JSON, so a confidential payload does not leave your machine. You can verify this: open your browser DevTools, switch to the Network tab, and convert something — no request carries your data. Two things to know: your last input is saved in your browser's localStorage (clear site data to remove it), and the Copy Link button embeds your JSON in the link, so anyone who opens that link, and the server that receives the request, can see it. Only share such links where you are comfortable with that.
No. The generator is free to use with no sign-up and no usage limits.
Each nested JSON object becomes its own named type, derived from the key it appeared under. Arrays of objects are widened across every element, so a field that is a whole number in one element and a fraction in another gets a type that holds both.