JSON to TypeScript
Generate TypeScript interfaces and types from a JSON document, locally in your browser. Nested interfaces, arrays, optional fields and unions — no upload.
🔒 Your JSON stays in your browser. Nothing is uploaded.
What does this tool do?
JSON to TypeScript turns the structure of a JSON document into TypeScript
interfaces and type aliases. Paste a JSON object or array and it infers the
types you would otherwise write by hand: nested objects become nested
interfaces, arrays become T[], and missing fields become optional properties.
How the inference works
The generator follows a small, predictable set of rules:
- Objects become interfaces. Each object — the root, nested objects and objects inside arrays — gets its own named interface.
- Arrays of objects are merged. When array items differ, their shapes are
merged and fields missing in some items become optional (
name?: string). nullbecomes a union. A field that isnullin one item andstringin another is inferred asstring | null.- Incompatible types become unions. A field holding both numbers and strings
is inferred as
number | string. - Empty arrays become
unknown[]. With no items, there is nothing to infer from, so the tool says so explicitly instead of guessing. - Names are normalized.
snake_case,kebab-caseandcamelCasekeys are converted to PascalCase (user_profile→UserProfile), arrays are singularized (users→User), and keys that would not be valid TypeScript identifiers are fixed.
When to use it
- Typing an API response you have as a sample payload.
- Bootstrapping types for a config file or fixture before tightening them.
- Generating a starting point you then refine into a hand-written type.
It is a structural converter: it reads shapes, not runtime semantics. It
does not know that 2026-09-10 is a date or that "1" should be a number —
it reports what is actually there.
JSON to TypeScript vs the rest of the JSON tools
- JSON Formatter beautifies raw JSON.
- JSON Validator checks syntax and reports errors with position.
- JSON Query extracts data from a document.
- JSON to TypeScript generates static types from the structure.
Each answers a different question about the same document.
Limitations
- Inference is structural and lossy: it cannot recover information that is not
in the sample (empty arrays,
null-only fields). - Array item merging is heuristic; genuinely mixed arrays become unions or optional fields rather than a single perfect type.
- Generated names are a best effort for pluralization and casing — rare keys may need manual renaming.
Privacy
Your JSON is parsed and converted locally in your browser. Nothing is uploaded, stored or sent anywhere.