JSON to TypeScript Interface

Generate TypeScript interface or type definitions from JSON. Handles nested objects, arrays, and null values.

Input data is processed in your browser
Data is never sent to a server

Tool

Root name
Indent:

or drag & drop a file

What is the JSON to TypeScript Interface Converter?

This tool generates TypeScript interface or type definitions from JSON — perfect for quickly typing API responses, configuration files, or any JSON data structure.

Nested objects are expanded into separate named interfaces, arrays are typed from their element types, and all generated interfaces are output in dependency order so the result is ready to use immediately.

How to Use

  1. Paste your JSON into the left panel. TypeScript type definitions are generated instantly on the right. Click "Sample" to see an example.
  2. Enter an interface name in the "Root name" field (default: Root).
  3. Enable "Make properties optional" to add `?` to all properties.
  4. Enable "Add readonly modifier" to prefix all properties with `readonly`.
  5. Enable "Use type instead of interface" to output `type =` syntax instead of `interface`.
  6. Enable "Represent null as | null" to type null values as `unknown | null`.

FAQ

How are nested objects handled?

Each nested object is converted into its own named interface and referenced from the parent type. Interfaces are output in dependency order so the result can be pasted directly into a TypeScript file.

How are arrays handled?

The tool inspects all elements in the array and unifies their types. For arrays of objects, all keys across all elements are merged into a single interface.

Can I paste a real API response JSON?

Yes. You can paste JSON copied directly from your browser's developer tools or from an API response body.

Can I edit the generated code?

The output is shown in a read-only textarea. Use the "Copy" button to copy it to the clipboard, then paste and edit it in your editor.