Data Format Conversions

JSON to TypeScript Interface Generator

Generate TypeScript interfaces or type aliases from sample JSON. Nested objects get their own named types, arrays of objects are merged so keys missing from some items become optional, and nulls become union types.
Runs in your browserLive result

Workspace

Options

How to use this tool

  1. 1Paste a sample JSON response or open a .json file.
  2. 2Name the root type and choose interfaces or type aliases.
  3. 3Review the generated types; optional fields end in ?.
  4. 4Copy them or download a .ts file.

Frequently asked questions

After their key in PascalCase, singular for array items: a "users" array of objects becomes User[]. Objects with an identical shape share one type.

When an array holds several objects, the tool merges them. A key missing from at least one item is optional; a key that is sometimes null gets "| null".

They are exact for the sample you paste. Real data may hold other values (for example a number that is sometimes a string), so review fields that come from user input.

No. The conversion runs in your browser with JavaScript. Your file or pasted text is not uploaded, logged or stored by MuhammadLab.