JSON to TypeScript Interface Generator

Turn a sample JSON object into TypeScript interfaces or type aliases.

About this tool

Paste a sample JSON object or array and get matching TypeScript interface declarations (or type aliases), including nested objects and arrays. This saves the tedium of hand-writing types for an API response or config file you already have real data for.

Types are inferred from a single sample — if a field is sometimes a different type or missing in other real responses, double-check the generated type against your actual data. The result is syntax-highlighted (toggle "Raw" for a plain copyable textarea); everything runs locally in your browser.

Example

JSON sample
{
  "id": 42,
  "name": "Ada",
  "active": true,
  "roles": ["admin", "staff"],
  "profile": { "city": "London", "verified": false }
}
TypeScript
interface Root {
  id: number;
  name: string;
  active: boolean;
  roles: string[];
  profile: Profile;
}

interface Profile {
  city: string;
  verified: boolean;
}

Nested objects are pulled out into their own named interface; arrays become T[].

Frequently asked questions

How are arrays typed?
An array of objects is merged into one nested interface using the union of keys seen across its elements — keys not present in every element are marked optional (?). An array of primitives (numbers, strings) becomes type[], or a union like (string | number)[] if the values are mixed.
What happens with null values?
A field that is null in your sample is typed as null — you'll likely want to widen it manually to something like string | null once you know the field's real type from other samples.
Why does a property name have quotes around it in the output?
JSON keys that aren't valid TypeScript identifiers (containing spaces, starting with a digit, etc.) are automatically wrapped in quotes, since TypeScript requires that for such property names.
Is my JSON uploaded anywhere?
No — parsing and type generation both happen entirely in your browser.