Add valid JSON
Paste an object or array, or open a local .json file. Nested structures and representative array records produce the best types.
Generate clean TypeScript definitions from real JSON data. Infer nested object types, array element types, nullability, property names, and mixed-value unions without uploading your data.
Generate reusable TypeScript definitions in three focused steps.
Paste an object or array, or open a local .json file. Nested structures and representative array records produce the best types.
Choose interfaces or type aliases, name the root type, and let the converter merge object shapes and value types.
Review the definitions, copy them into your project, or download a ready-to-use .ts file.
The generator examines complete structures rather than guessing from the first property alone.
Objects inside objects receive clear named definitions instead of unreadable inline blocks.
Multiple object records are inspected to identify shared, optional, nullable, and differing properties.
Property names that are not legal TypeScript identifiers are quoted automatically and safely.
JSON parsing and type generation happen locally in your browser without a server upload.
Each JSON value maps to a TypeScript type: strings to string, numbers to number, booleans to boolean, null values to null, arrays to element arrays, and objects to named definitions.
When an array contains several objects, the generator merges their keys. A property missing from some records becomes optional, while values with different shapes become union types.
Generated types describe the sample you provide. Include realistic records, null states, and variant values so the output reflects the API payload accurately.
// JSON { "id": 42, "name": "Alex", "roles": ["admin", "editor"] } // TypeScript export interface Root { id: number; name: string; roles: string[]; }
Practical details about inference, arrays, nulls, and generated definitions.
Yes. Nested objects receive their own named interfaces or type aliases, and nested arrays are inferred recursively.
All object samples in the array are merged. Missing keys become optional, and differing value types are combined into unions.
A null-only sample becomes the null type. When another record provides a concrete value for the same property, the result becomes a union such as string | null.
Yes. Clear the interface option to produce exported type aliases for object definitions.
Yes. Keys containing spaces, hyphens, or other characters are quoted so the generated TypeScript remains valid.
An empty array does not contain enough evidence to infer an element, so it is generated as unknown[].
No. Parsing, inference, copying, and downloading happen locally inside your browser.
Yes. The definitions describe the supplied sample. Compare them with your API contract, especially when optional or rare fields may be absent.