JSON to TypeScript

Paste JSON to generate TypeScript interfaces

About this tool

Paste any JSON object and get ready-to-use TypeScript interfaces or type aliases. Nested objects become their own interfaces, object arrays merge all their keys, and optional fields are inferred automatically — all locally in your browser.

How to use
  1. Paste your JSON into the input box.
  2. Set the root type name and choose whether to add export.
  3. Copy the generated TypeScript definitions.
How are arrays with mixed element types handled?

Elements are merged into a union, so [1, "a"] becomes (number | string)[]. Arrays of objects merge every element's keys, and keys missing from some elements become optional (key?:).

Why does an empty array become unknown[]?

An empty array carries no element to inspect, so the element type cannot be inferred and is emitted as unknown[]. Replace it with the concrete element type you expect.

How is null handled?

A null value marks that field optional (key?) and keeps null in its type, e.g. name?: string | null.

Is my JSON uploaded anywhere?

No. Parsing and type generation run entirely in your browser.