AZ Tools

JSON → TypeScript Interface

Developer

Paste a JSON sample (an API response, a config, a fixture) and get back a ready-to-paste TypeScript interface. Nested objects become their own interfaces named after the parent key (in PascalCase), arrays infer the element type, and primitives stay primitives. Merge mode walks every element of an array to produce a union; first-only mode infers from element zero (faster for huge arrays).

TypeScript
export interface Post {
  id: number;
  title: string;
  tags: string[];
}

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

export interface Root {
  id: number;
  name: string;
  active: boolean;
  joinedAt: string;
  roles: string[];
  address: Address;
  posts: Post[];
}

How to use

  1. Paste a JSON sample.
  2. Set a root type name and choose interface or type-alias style.
  3. Pick array handling — merge (safer) or first (faster).
  4. Copy the generated TypeScript.

Frequently asked questions

Why does my array of users produce a User interface?
Keys that look plural (users, posts, tags) are singularized for the nested type name. So 'posts': [...] generates a Post interface, used as Post[].
What does merge vs first do?
Merge walks every array item and unions the field types, so 'optional' fields that are missing in some items become 'field?'. First only looks at item zero — fast but misses union types and optionality.
Are dates inferred as Date?
No — TypeScript can't tell a date string from any other string at compile time. The tool keeps them as 'string' so the output is correct in strict mode.
What about null?
null becomes its own type. If a field is sometimes null in merge mode, you get 'field: string | null' instead of 'field: string'.

Related tools