JSON to TypeScript

Paste JSON, get TypeScript interfaces and a matching Zod schema.

Runs locally · nothing uploaded
JSON

What it does

Paste a JSON sample, such as an API response from your ASP.NET Core backend or a webhook payload, and get TypeScript declarations you can drop into a frontend project. The output updates as you type, and a second tab shows the same model as a Zod schema for runtime validation.

How it infers types

  • Every array item is examined, not just the first. A key missing from some items becomes optional (name?: string). A key that is sometimes null becomes string | null.
  • Mixed arrays become unions, e.g. (string | number)[]. An empty array becomes unknown[].
  • Identical shapes are declared once. shippingAddress and billingAddress with the same properties share one Address interface.
  • Objects keyed by IDs ({"101": {...}, "102": {...}}) become Record<string, T>.
  • Valid output every time: property names that are not identifiers ("first-name", "2fa") are quoted. Type names are PascalCase and singular for array items. Names that would shadow built-ins like Date or Error get a suffix.
  • ISO date strings stay string by default, with a comment saying they are a date or date-time. You can also type them as Date if you revive them after parsing. The Zod schema checks them with .datetime() or .date() (Zod 3.23 or later).

Options

Choose interface or type, toggle export and readonly, pick T[] or Array<T>, and set the root type name. A root array produces an item type plus a ...List alias.

How to use it

Paste JSON or drop a .json file, then copy or download the TypeScript or Zod output.

Privacy

The conversion runs entirely in your browser. Your JSON is never uploaded; the last input is kept in local storage.