JSON to TypeScript

Generate TypeScript interfaces or type aliases from a JSON sample.

JSON input
TypeScript

About this tool

Paste a JSON sample and get TypeScript declarations for it. Every nested object becomes its own interface (or type alias) named after its key, and arrays become T[].

Type mapping

  • Numbers → number, text → string, true/false → boolean, null → null.
  • Empty arrays → unknown[]; arrays with mixed values → unions such as (string | number)[].
  • Objects inside arrays are merged: a key missing from some items is marked optional (?), a key that is sometimes null gets | null.
  • Keys that are not valid identifiers (e.g. first-name, or the empty key "") are quoted.

Options

All properties optional adds ? everywhere, useful for partial payloads. camelCase renames keys — only use it when your code maps names, since the types will no longer match the raw JSON.

Privacy

Code is generated entirely in your browser. The JSON you paste is never uploaded, stored or logged.