Skip to content
TextArray
100% local

JSON to TypeScript

Generate TypeScript interfaces from a JSON document, with nested objects as named sub-interfaces.

Input

JSON to TypeScript

Paste a JSON document — an API response, a config file, a database row — and get ready-to-use TypeScript declarations. Types are inferred recursively: primitives map to string, number and boolean, arrays carry their element type, and mixed arrays become clean unions such as (number | string)[]. Every nested object becomes a named sub-interface derived from its property key in PascalCase, so a "user" property produces a User interface you can import and reference anywhere.

Identical shapes are detected and reuse a single interface instead of generating duplicates; a numeric suffix appears only when two objects share a key name but differ in structure. Empty arrays come out as unknown[] and empty objects as Record<string, unknown> — honest placeholders rather than guesses. Property names that are not valid identifiers are quoted automatically, so kebab-case and numeric keys survive intact.

The options cover real project conventions. Name the root type, choose between interface and type declarations, export everything or nothing, mark all properties readonly, and decide how null values are treated — as an explicit null type or as optional properties. Invalid JSON produces a calm error with the line and column of the problem, the same way the JSON formatter reports it.

Everything runs locally in your browser: API responses with tokens, user records or internal payloads never leave your machine. Paste, copy the declarations into your codebase, and the shape of your data is typed.

FAQ

How are nested objects and arrays typed?
Nested objects become named sub-interfaces derived from their property key in PascalCase. Arrays take their element type; when elements differ, the type is a union such as (number | string)[]. An array of same-shaped objects reuses one interface for all elements.
What happens with two objects of the same shape?
They share one interface — the generator compares structures and reuses the first name. A numeric suffix like Item2 appears only when two properties have the same key but genuinely different shapes.
How are null values handled?
By default a null property is typed as null, which is exactly what the sample says. Turn on "Optional properties for null values" to emit prop?: unknown instead — useful when null means "sometimes absent" in your API.
Why is my empty array typed as unknown[]?
An empty array carries no evidence of its element type, so unknown[] is the honest answer. Add one representative element to the sample and the generator infers the real type.
Is my JSON uploaded anywhere?
No. The tool runs entirely in your browser and your data never leaves your device — safe for API responses that contain tokens or personal data.