JSON to TypeScript
What is JSON to TypeScript?
JSON to TypeScript is a free online tool that infers TypeScript types from a live JSON payload. Paste a response body, config file or fixture and get clean, ready-to-use interfaces — with nested objects extracted into named interfaces, array item shapes merged into one, and structurally identical objects deduplicated into a single shared interface.
Features
- Shape merging across array items — keys from every item merge into one interface; keys missing from some items become optional (or
| undefinedwhen you prefer strict required fields) - Smart naming — nested objects are named from their key path (RootUser, RootUserAddress), array items get a mechanical Item suffix, and name collisions get deterministic numeric suffixes
- Structural dedupe — objects with identical shapes share a single interface, referenced everywhere it occurs
- Unions for mixed content — mixed arrays become union types, null-valued fields become
| nullunions, and empty collections fall back tounknown[]orRecord<string, unknown> - Deterministic output — same input, byte-for-byte same output: union members sorted, declarations in first-seen order, two-space indentation
How to use
Paste JSON into the input panel and the TypeScript appears live. Set a root name, toggle the export keyword, and choose whether partially-present fields become optional or stay required with | undefined. Copy the result with one click.
One caveat: JavaScript objects reorder integer-like keys ("1", "2", ...) before string keys, so a JSON object with numeric-looking property names may emit those properties first — a language-level behavior, not something the tool can or should fight.
Privacy
Generation in the browser UI runs locally on your device — pasted data is not uploaded. (A public API endpoint also exists for programmatic use; anything you send there is, by definition, transmitted.)