JSON to TypeScript Type

This page starts in type alias mode. Use it when you prefer export type over export interface for object shapes.

JSON to TypeScript converter

Types update as you type. Conversion runs in this browser and is not posted to a conversion API.

TypeScript output
// Generated locally in your browser. No data was sent to a server.

export enum Status {
  Complete = "complete",
  Draft = "draft",
}

export type Profile = {
  email: string;
  score: number;
};

export type Project = {
  title: string;
  status: Status;
};

export type RootObject = {
  id: number;
  name: string;
  active: boolean;
  role: string;
  profile: Profile;
  tags: string[];
  projects: Project[];
};

Type aliases from a JSON sample

Switching Output to Type aliases changes object emission to export type Name = { ... } while keeping nested extraction, optional keys, and enums. Indent and null handling still apply.

Root values that are arrays or primitives were already type aliases. This page makes object roots use the same keyword so a file of generated types stays consistent.

Limits

Type aliases do not declaration-merge. If you need to extend the shape in another file, use the interface converter. JSON Schema and Zod are not accepted as input.

FAQ

Is the inferred shape different from interface mode?

No. Only the emission keyword changes for objects. Nested extraction, optional keys, and unions are the same inference.

Why is my root still a type alias in interface mode?

If the JSON root is an array, TypeScript cannot express it as an interface. Both pages emit export type Root = Item[] in that case.

Can I download the aliases as a file?

Yes. Use Download .ts after the output looks right.

Part of JSON to TypeScript Converter. Conversion still runs in the browser on this page.