JSON to TypeScript

Infer TypeScript interfaces or type aliases from JSON, including nested objects, merged array shapes, unions, nulls, and empty arrays.

Runs entirely in your browser. Nothing you type is uploaded.

About this tool

Paste valid JSON, choose a root name and declaration style, then generate TypeScript locally. Configure semicolons, readonly and optional properties, and null handling; object shapes in arrays are merged and missing fields become optional.

Questions & answers

How are objects with different fields in one array handled?
Their object shapes are merged. Fields missing from some elements become optional, while conflicting primitive types become a union.
What type is generated for an empty array?
An empty array becomes unknown[] because it contains no values from which a safer element type can be inferred.
What happens to JSON keys that are not TypeScript identifiers?
They are emitted as quoted property names, while generated type names are normalized to valid identifiers.

Related tools

Back to all Mini Tools