JSON to TypeScript

Generate TypeScript interfaces or type aliases from any JSON object.

JSON Input
TypeScript Output

TypeScript interfaces will appear here

Ready
Paste JSON and generate TypeScript
0
Interfaces
0
Properties
0
Depth
Free Code Generator

JSON to TypeScript Interface Generator

Paste any JSON object and instantly generate clean TypeScript interfaces or type aliases. The generator handles nested objects, arrays, all primitive types, and optionally marks every property as readonly or optional. All conversion runs in your browser — no data is sent to a server.

How to generate TypeScript from JSON

  1. Paste your JSON into the input panel.
  2. Set the root interface name (default: Root).
  3. Choose interface or type alias output.
  4. Optionally enable optional or readonly modifiers.
  5. Click Generate TypeScript.
  6. Copy or download the .ts file.

Features

  • Generates interface or type alias output.
  • Handles nested objects as separate named interfaces.
  • Detects arrays and uses Type[] notation.
  • Maps JSON types: string, number, boolean, null → string | null, arrays.
  • Optional readonly and optional property modifiers.
  • Download as .ts file or copy to clipboard.

Generate types from an API response

Paste {"id":42,"active":true} with the default root name to get a Root interface with id: number and active: boolean. Replace Root with a name that describes the response.

For arrays, the generator uses the first item as the example. Check any later items with missing fields or different types, and edit the generated interface to match the API contract. Use JSON Compare to spot changes between examples.

Frequently Asked Questions

How are nested objects handled?

Each nested object becomes its own separate named interface. The property type in the parent interface references the child interface by name, keeping the output clean and modular.

What TypeScript type is used for null values?

When a value is null in the JSON, the generator uses null as the type. If you also want to express that the field may sometimes have a real value, consider editing the output to use a union type like string | null.

How are arrays handled?

If an array contains objects, a new interface is generated for the element type and the property uses ElementType[]. Arrays of primitives use string[], number[], etc.

Is my JSON sent to a server?

No. All generation runs entirely in your browser. Your JSON never leaves your device.