All tools

JSON to TypeScript

Generate a TypeScript interface from a JSON sample.

TypeScript
interface Root {
  id: number;
  name: string;
  active: boolean;
  tags: string[];
  address: Address;
}

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

About

Paste a JSON value and get a TypeScript interface that matches it. Nested objects become nested types. Arrays of objects produce a single shared type. Optional fields aren't inferred (every key is required).

How to use

  1. Paste a JSON value.
  2. Set the root type name.
  3. Copy the generated TypeScript.

FAQ

Does it pick up unions across array elements?+

Yes. If two array entries have different shapes, the result is a union of both. If they match, it collapses to a single type.