JSON Parser

JSON to TypeScript Interface Generator

Paste any JSON and get TypeScript interfaces for it. Nested objects become their own interfaces, arrays become typed arrays, and everything runs in your browser, so API responses and payloads stay private.

How to generate TypeScript from JSON

  1. Paste your JSON (or upload a file). The interfaces appear as you type.
  2. Click Copy and paste them into a .ts or .d.ts file.
  3. Rename interfaces as you like; the names are taken from the JSON keys.

Example

JSON

{
  "user": {
    "id": 1,
    "name": "Alice",
    "tags": ["a", "b"],
    "address": { "city": "NYC" }
  },
  "active": true
}

TypeScript

interface Root {
  user: User;
  active: boolean;
}

interface User {
  id: number;
  name: string;
  tags: string[];
  address: Address;
}

interface Address {
  city: string;
}

How types are inferred

JSON valueTypeScript
stringstring
number (whole or decimal)number
true / falseboolean
nullnull
array of one typestring[]
array of mixed types(string | number)[]
empty arrayunknown[]
objectits own interface, named from the key
  • For arrays of objects, the item interface is built from the first object, so put the most complete example first. Fields that appear only in later items won't be included.
  • Keys that aren't valid identifiers (such as first-name) are quoted automatically.
  • Optional fields (?) are not inferred, because one sample can't show which fields may be missing. Add ? by hand where needed.

Related tools

Describe the same data with the JSON Schema generator, validate it with the schema validator, or generate code for other languages with Java, Go, Python and C#.

Handles JSON files up to 20MB smoothly