IQ
PayloadIQ
PayloadIQ Utilities

JSON to TypeScript

Paste a JSON sample and get clean TypeScript interfaces back. Nested objects become their own interfaces, arrays of objects are merged, and optional keys and nulls are inferred — all in your browser.

TypeScript interfaces appear here.

Runs in your browser. Your input is not uploaded to PayloadIQ.

JSON to TypeScript turns a JSON sample into typed interfaces you can paste straight into your codebase. The shape is inferred from your example: nested objects become their own named interfaces, arrays of objects are merged into one representative interface, keys missing from some elements become optional (?), and a value that is null in your sample becomes a | null union. Everything runs locally in your browser, so a real API response never leaves your machine.

Readable interfaces, not one giant inline type

Rather than collapsing everything into a single nested literal, each object shape is hoisted into its own export interface with a name inferred from the field. That keeps the output easy to read, easy to import, and easy to extend — the same way you would model the types by hand.

Inference is sample-driven

The generator can only see what you give it, so paste the richest payload you have — for lists of objects it merges the keys across elements and marks any that are missing as optional. Want types in another language (Python, Go, Rust, Prisma, Zod) or a full typed client and schema report from the same payload? Open it in the PayloadIQ playground, or read the in-depth JSON to TypeScript guide.

FAQ

Is my JSON uploaded?
No. The JSON is parsed and converted entirely in your browser with JavaScript — it never leaves your device. That makes it safe for real API responses, auth payloads, and anything internal.
How are nested objects and arrays handled?
Each nested object becomes its own named interface, so the output stays readable instead of one giant inline type. An array of objects is merged into a single representative interface: keys present in only some elements become optional (?), and a key that is null in some elements keeps its real type and gains | null.
How complete is the inference?
It is only as complete as the sample you paste, so use the richest, most representative payload you have. For arrays it samples up to 200 elements and unions their keys, marking any that are missing as optional. An empty array becomes unknown[] because there is nothing to infer from.
What about keys that aren't valid identifiers?
They are quoted in the interface (for example "user-id": string) so the generated TypeScript always compiles. Keys used to name child interfaces are sanitized — a userId field, for instance, suggests a User interface.

Related utilities

JSON to PythonJSON Formatter / ValidatorJSON to YAMLGuide: JSON to TypeScriptJSON VisualizerJSON MinifierJSON DiffJSON to CSV
Open PayloadIQ Playground