JSON to TypeScript Converter

Paste a JSON sample, such as an API response, and get ready-to-use TypeScript interfaces. Nested objects become their own named types.

Free · Runs in your browser · Your text is never uploaded

A JSON object converted into a TypeScript interface

How the JSON to TypeScript converter works

The converter reads your JSON sample and works out a type for every value. Strings, numbers and booleans map directly. Objects become named interfaces, and arrays become T[]. When an array holds several objects, their shapes are merged: a key that is missing from some items becomes optional (age?: number), and a key whose value differs between items becomes a union such as string | null.

Tips for accurate types

  • Use a sample that includes optional fields and null values, because a type can only describe what the sample shows.
  • An empty array becomes unknown[], since there is nothing to infer from.
  • Check numbers that are sometimes whole and sometimes decimal: TypeScript uses one number type for both.
  • For production code, treat the output as a starting point and review names, optional fields and enums.

Interface or type alias?

Both describe object shapes. Interfaces can be extended and merged, and are the usual choice for API data. Type aliases are more flexible for unions. This tool offers both.

Everything runs in your browser. Nothing you paste is uploaded, logged or stored, so it is safe to use with private data.

Related guides

Popular json to typescript converter presets

Frequently asked questions

How do I convert JSON to a TypeScript interface?

Paste your JSON into the box. The interfaces appear on the right and can be copied straight into your project.

How are optional properties detected?

When the JSON contains an array of objects and a key is missing in some of them, that property is marked optional with a question mark.

Does it handle nested objects and arrays?

Yes. Every nested object becomes its own named interface, and arrays of objects are merged into one shared interface.

Is my JSON uploaded anywhere?

No. The conversion runs in your browser, so API responses with private data stay on your device.