JSON to TypeScript Converter

Paste any JSON and get clean TypeScript interfaces — nested types, unions, and nullables inferred automatically.

Advertisement

How it works

Paste any JSON value — an object, an array, or a primitive. The converter walks the structure recursively: nested objects become named interfaces ("address" → interface Address), arrays of objects are merged so optional fields and union types are detected across all samples, and keys that aren't valid identifiers are safely quoted. Choose between export interface, plain interface, or export type output.

Typing rules

Arrays become elementType[]; mixed arrays become unions like (string | number)[]; null values produce | null unions; empty arrays fall back to unknown[]. Paste an array of sample responses and any key missing from some samples is marked optional with ? — the closest a generator can get to a real schema from examples alone.

FAQ

How are nested JSON objects handled?
Each nested object becomes its own interface, named after its property key in PascalCase — e.g. an "address" object becomes interface Address. Arrays of objects are merged into one interface.
How are arrays, nulls, and mixed types handled?
Arrays become elementType[]; mixed arrays become unions like (string | number)[]; null values add a | null union; empty arrays fall back to unknown[]. Every union is deduplicated automatically.
How do I get optional (?) fields?
Paste an array of sample responses instead of a single object. Keys that are missing from some samples are marked optional with ?. A single object produces all-required fields.
Is my JSON uploaded anywhere?
No. Type inference runs entirely in your browser with JavaScript — your data never leaves your device.
Advertisement