>_
TS

JSON to TypeScript

Convert JSON into TypeScript interfaces or type aliases. Infers nested objects, arrays, optional fields and union types — locally in your browser.

Runs locally — your input never leaves this page.

Declaration

How to use

  1. Paste a JSON sample (for example an API response) into the left panel.
  2. Set the root type name and choose between interface and type declarations.
  3. The TypeScript definitions update instantly. Nested objects become their own named types.
  4. When an array contains objects with different keys, missing keys are marked optional (?).

FAQ

How are arrays of mixed types handled?

Element types are merged: objects are combined into one type with optional fields for keys that are not always present, and different primitives become a union such as (string | number)[].

What happens with null values?

A field that is always null is typed as null. If it is null in some samples and has a value in others, it becomes a union like string | null.

Are invalid identifiers supported as keys?

Yes. Keys such as first-name or 2fa are quoted automatically so the output always compiles.

Report a bug or suggest a feature →