Developer

JSON to TypeScript

Convert JSON into TypeScript interfaces and type aliases instantly.

All tools

JSON

TypeScript

export interface Profile {
  email: string;
  verified: null;
}

export interface Root {
  id: number;
  name: string;
  active: boolean;
  roles: string[];
  profile: Profile;
}

Frequently asked questions

How are optional fields detected when generating TypeScript from JSON?
From a single sample, every field looks required - the generator cannot know a property may be absent in other payloads. Provide multiple representative samples or manually mark fields with ? after generation.
What's the difference between an interface and a type alias?
Both can describe object shapes, but interfaces can be merged across declarations and extended naturally, while type aliases can represent unions, intersections, and primitives that interfaces cannot. For plain object shapes either works.
How are arrays with mixed types represented?
Mixed arrays become a union element type like (string | number)[], or an unknown[] if the values vary too widely. Tuples with fixed positions can be expressed as [string, number] if you tighten the result by hand.