JSON to TypeScript Interface

Paste a JSON object or array to generate TypeScript interfaces with nested types. Objects in arrays are merged into one interface, with keys missing from some items marked optional.

TypeScript Output
interface Address {
  street: string;
  city: string;
}

interface Root {
  id: number;
  name: string;
  email: string;
  active: boolean;
  score: unknown | null;
  address: Address;
  tags: string[];
}

About This Tool

How to Use
  1. Paste your JSON (an object or an array) into the left input panel
  2. TypeScript interfaces are generated automatically as you type
  3. Enter a custom root name in the field provided
  4. Toggle between interface and type alias output, and enable readonly or optional modifiers as needed
  5. Click Copy or Download .ts to use the generated TypeScript
Common Use Cases
  • Generating TypeScript types from REST API response payloads
  • Creating interfaces from JSON configuration file structures
  • Scaffolding types from database query result shapes
  • Converting JSON Schema examples into TypeScript definitions
Tips & Tricks
  • Nested objects are extracted into separate named interfaces automatically
  • Objects in an array are merged into one interface; keys missing from some items become optional
  • Values that are sometimes null produce nullable types (Type | null); choose how null-only fields are typed
  • Names that would clash with built-in types (Date, Error, Array) get a Type suffix

Related Tools