Code Generators · Runs in your browser

JSON to TypeScript Interface Generator

Paste a JSON sample and get ready-to-use TypeScript interfaces, with nested types, arrays and optional fields worked out for you. Ideal for typing API responses in React, Angular, Vue or Node.

JSON
Drop a file to load it
TypeScript
Waiting for input

How to use it

  1. Paste a representative JSON sample, such as an API response.
  2. Set the root type name and pick a style: interfaces or type aliases.
  3. Copy the TypeScript code or download it as a file.

Optional fields

A key that only some array items have becomes optional (note?: string). Keys that aren’t valid identifiers are quoted, so "user-name" works.

Union types

A field that holds different types across items gets a union, such as string | number.

Integers vs. decimals

Number types come from how the number is written in your sample: 3 is an integer, 3.0 and 3.5 are decimals, and long IDs use a 64-bit type.