Paste a JSON payload and get TypeScript interfaces for it, including every nested object, named sensibly from the keys that hold them. Arrays of objects are merged into a single type covering all their elements, with fields that only appear in some of them marked optional — which matters, because generating a type from just the first element produces something that fails to compile the moment a record omits a field, and that is exactly what most generators do. Mixed arrays become unions, empty arrays become unknown[] so the compiler keeps checking them rather than giving up, and identical shapes are deduplicated instead of producing near-duplicate interfaces. Keys that are not valid identifiers are quoted properly. It runs entirely in your browser, which matters when the payload you are typing is a real API response with real data in it.
| JSON | TypeScript | Why |
|---|---|---|
| {"id": 1} | id: number; | Direct primitive mapping |
| {"tags": ["a"]} | tags: string[]; | Element type from the contents |
| {"v": []} | v: unknown[]; | any[] would disable checking |
| [{"a":1},{"a":1,"b":2}] | b?: number; | Missing from one element |
| {"m": [1, "a"]} | m: (number | string)[]; | Mixed array becomes a union |
| {"n": null} | n: null; | Preserved, not dropped |
| {"kebab-key": 1} | "kebab-key": number; | Not a valid identifier |
By comparing every object in an array. If a key appears in some elements but not others, it is marked with a question mark. The more representative your sample, the more accurate that is — a single-element array cannot tell the tool which fields are optional.
Because an empty array tells you nothing about the element type, and any[] silently switches off type checking for everything downstream. unknown[] keeps the compiler honest and forces you to narrow the type deliberately.
After the key that holds them, converted to PascalCase, and singularised for arrays — so a users array produces a User interface and categories produces Category. Identical shapes are deduplicated, so two properties with the same structure share one interface rather than getting two nearly identical ones.
Null is kept as a union member and sorted last, so you get string | null rather than the null being silently dropped. If a value is null in your sample but a string in reality, you will need to widen the type yourself — a sample cannot tell the difference.
Treat it as a starting point. A sample payload cannot express constraints a real schema has: enums, formats, ranges, or fields that happen to be absent from your sample but exist in the API. It saves the tedious part; the judgement is still yours.
No. Parsing and generation happen in your browser. API responses pasted here — which routinely contain real customer data and tokens — are never sent to a server, logged, or stored.
The JSON is walked depth-first and every object becomes a named interface, with nested types named after the key that holds them, converted to PascalCase and singularised for arrays so a 'users' array yields a 'User' interface. The part that makes the output actually compile is array merging: rather than typing the first element and hoping the rest match, every object in an array is merged into one shape that is the union of all their keys, and any key that does not appear in every element is marked optional. Typing only the first element is the common shortcut and it produces interfaces that fail against the real payload the moment a record omits a field. Mixed-type arrays become parenthesised unions, empty arrays become unknown[] rather than any[] so the compiler keeps checking them, and null is preserved as a union member sorted last for readability. Identical shapes are deduplicated by signature, so two properties with the same structure share one interface instead of producing near-duplicate types. Keys that are not valid TypeScript identifiers — kebab-case, leading digits, embedded spaces — are quoted, and a generated type name that collides with a reserved word is suffixed. All parsing happens locally.