TapToolsCoffee
All tools

JSON to TypeScript

Developer Tools

Paste JSON and get strict TypeScript interfaces or types, with nested objects handled.

JSON input

TypeScript output

export interface Root {
  id: number;
  name: string;
  active: boolean;
  nickname: null;
  tags: string[];
  address: Address;
  projects: Project[];
}

export interface Project {
  title: string;
  year: number;
  pages?: number;
}

export interface Address {
  city: string;
  zip: string;
}

What is the JSON to TypeScript Interface Generator?

The JSON to TypeScript Interface Generator reads a JSON sample, such as an API response, and writes matching TypeScript interfaces or type aliases. Nested objects get their own named interfaces, arrays get element types, and keys missing from some array items become optional.

How to use this tool

  1. Paste your JSON into the left box.
  2. Set the root name and choose interface or type.
  3. Copy the code or download it as a .ts file.

Frequently Asked Questions

All items are merged into one interface. A key that is missing from some items is marked optional, and keys with different value types become a union.

unknown[], since there is no sample value to infer from. Replace it with the real type once you know it.

No. Everything runs in your browser, so nothing is uploaded to a server.