JSON to TypeScript

Paste JSON and instantly get TypeScript interfaces or types. Handles nested objects, arrays and optional fields. Free, private, runs in your browser.

How to convert JSON to TypeScript

  1. Paste a JSON object or array into the left box, for example an API response.
  2. Choose a root name and whether you want interface or type declarations.
  3. Copy the generated TypeScript from the right box into your project.

Nested objects become their own named interfaces, so the output stays readable even for large payloads. Array property names are singularized, so a users array produces aUser interface.

Tips for accurate types

The generator can only see the sample you give it. Paste a response that includes optional fields and several array items, so it can detect which properties are sometimes missing. For runtime validation of untrusted data, pair these types with a schema library such as Zod.

Frequently asked questions

Is my JSON sent to a server?

No. The conversion runs entirely in your browser with JavaScript, so the JSON you paste never leaves your device.

How are arrays of objects handled?

All objects in an array are merged into a single interface. A property that is missing from some of the objects is marked optional with a question mark.

Should I use interface or type?

Both work for describing JSON. Interfaces can be extended and merged, and many style guides prefer them for object shapes. Type aliases are needed for unions and for a root value that is an array.

Why is a property typed as null?

If every sample value of a property is null, there is no way to know its real type. Replace null with the expected type, for example string | null.