Paste JSON and generate TypeScript interfaces or type aliases, including nested objects and arrays — processed in your browser.
Your TypeScript interfaces will appear here after you generate them.
This tool reads a JSON example and generates matching TypeScript interface (or type) definitions. Nested objects become their own interfaces named after their key, and arrays of objects are merged into a single element interface.
{
"users": [
{ "id": 1, "name": "John" }
]
}interface Root {
users: User[];
}
interface User {
id: number;
name: string;
}Typing API payloads and configuration gives you autocompletion and compile-time safety. Generating types from a real response is faster and less error-prone than writing them by hand, and keeps your models aligned with the data you actually receive.
A single JSON example cannot express everything a type can. In particular:
null is typed as null — the intended type can’t be inferred from one example. Where a value is seen both null and typed, it becomes a union such as string | null.?.(number | string)[].Start from clean JSON — format it with the JSON Formatter or check it with the JSON Validator first.
It reads a JSON example and generates matching TypeScript interfaces (or type aliases), including nested objects and arrays, so you get typed models without writing them by hand.
Typing API payloads and config gives you editor autocompletion and compile-time safety. Generating from a real example is faster and less error-prone than writing types manually.
A property that is only ever null is typed as null, because a single example cannot reveal the intended type. Where a value appears both null and typed (for example in an array), it becomes a union such as string | null.
Arrays of objects are merged into one element interface; keys missing from some elements become optional. Mixed arrays become a union such as (number | string)[]. No values are silently discarded.
Property names that contain spaces, hyphens, or other special characters are quoted, e.g. "first-name": string; — the output is always valid TypeScript.