JSON to TypeScript

Infer TypeScript interfaces and type aliases from a JSON example.

Your JSON is parsed entirely in this browser and is never uploaded.

Generated types describe only the supplied sample, not every response your API may return. Review optional fields, unions, dates, enums, and business rules against the real contract.

TypeScript output

export interface ApiResponse {
  users: ApiResponseUsersItem[];
  nextPage: null;
}

export interface ApiResponseUsersItem {
  id: number;
  name: string;
  roles: string[];
  profile: ApiResponseUsersItemProfile;
  email?: string;
}

export interface ApiResponseUsersItemProfile {
  verified: boolean;
  bio: null | string;
}

3 interfaces · 0 type aliases

Inference rules

Missing keys across objects in the same array become optional. Mixed values become unions, empty arrays use unknown[], nested objects receive named interfaces, and invalid property names are quoted.

Related Tools