JSON to TypeScript Converter

Paste JSON from an API response or fixture and generate TypeScript interfaces or type aliases in your browser. Nested objects, arrays, null values, and optional fields are inferred from the sample you provide.

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 interface Profile {
  email: string;
  score: number;
}

export interface Project {
  title: string;
  status: Status;
}

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

What this converter accepts

The input must be valid JSON: an object, an array, or a primitive. Nested objects become named types. Arrays of objects are merged so fields that appear in only some items are marked optional. Empty objects emit an empty type, and empty arrays emit unknown[].

The sample JSON on the left is a real payload the tool converts immediately. Change the root name, switch between interfaces and type aliases, pick 2- or 4-space indent, then copy or download a .ts file.

Nested objects, arrays, null, and optional properties

A nested object such as profile is extracted into its own interface or type alias and referenced from the parent. Arrays of objects share one item type. When two records disagree on a key, that key is optional.

A field that is null in the sample is typed as null. If you prefer optional properties instead, use Null fields → Mark optional. Mixed arrays such as [1, "two", true] become a union.

Limits of sample-based inference

This tool infers types from one JSON value. It cannot see JSON Schema, OpenAPI, or runtime types your API might return later. A field that is always a string in production but happens to be missing in this sample will not appear. Enums are suggested only when a small set of short string tokens repeats.

Conversion runs in the page's JavaScript. The JSON you paste is not posted to a conversion API. Loading the website still uses HTTPS to the host, which may record ordinary request logs. See the Privacy Policy for details.

FAQ

How do I convert JSON to TypeScript interfaces?

Paste JSON in the left panel. Nested objects are extracted into interfaces (or type aliases if you change Output). Copy or download the result. Types also update as you type after a short pause.

Does this tool upload my JSON?

No conversion API is called. jsonToTypeScript runs in the browser. Visiting the site still makes a normal HTTPS request to the host; that request does not include the JSON you paste.

Can I convert a top-level JSON array?

Yes. Paste an array such as [{}] or a list of records. The tool emits an item type plus a type alias for the array.

How are null and missing properties handled?

Missing keys across array items become optional (?). A null value is typed as null unless you choose Mark optional, which adds ? to those fields.

When should I emit type aliases instead of interfaces?

Use Interfaces when you want extendable object shapes. Use Type aliases when you prefer export type Name = { ... }, or when the root value is already an array or union. See the Interface vs Type guide for details.

Is the converter free?

Yes. There is no account and no usage cap on this static page.