JSON to TypeScript Converter

Paste JSON and get clean, accurate TypeScript interfaces in real time — nested objects, arrays, and nullable fields included. Conversion runs entirely in your browser; your data is never sent anywhere.

Style
TypeScript output
// Your generated interfaces will appear here.

How to use the JSON to TypeScript converter

  1. Paste any valid JSON object or array into the JSON input panel, or click Load sample to try it with example data.
  2. Generated TypeScript interfaces appear instantly in the TypeScript output panel as you type.
  3. Optionally change the Root type name to match the interface name you want for the top-level shape.
  4. Use Copy to copy the output to your clipboard, or Download .ts to save it as a TypeScript file.

What it handles

  • ✓ Deeply nested objects, each promoted to its own named interface
  • ✓ Arrays of primitives and arrays of objects, with shape merging
  • ✓ Optional fields inferred when array items don't share every key
  • ✓ Nullable values, rendered as T | null
  • ✓ Clear error reporting for invalid or malformed JSON

Example

Input JSON

{
  "id": 1,
  "name": "Tayyab",
  "isActive": true,
  "address": {
    "city": "Lahore"
  },
  "tags": ["frontend", "typescript"]
}

Generated TypeScript

export interface Address {
  city: string;
}

export interface RootObject {
  id: number;
  name: string;
  isActive: boolean;
  address: Address;
  tags: string[];
}

FAQs

Does this tool send my JSON to a server?

No. Parsing and conversion run entirely in your browser with JavaScript. Your JSON is never uploaded or transmitted anywhere, which makes it safe to use with real API responses or data containing sensitive fields.

How are nested objects handled?

Each nested object gets its own named TypeScript interface, derived from the property name it was found under (for example, an "address" field produces an Address interface). Identical object shapes found in different places are merged into a single interface instead of being duplicated.

What happens with arrays of objects?

The tool inspects every item in the array and merges their shapes. Fields that appear on some items but not others are marked optional with a "?". If items disagree on a field's type, that field becomes a union type, such as "string | number".

How are null values typed?

A field that is null becomes the literal type "null". If the same field is also seen as a string, number, boolean, or object elsewhere, it becomes a nullable union such as "string | null".

What happens if my JSON is invalid?

The converter reports a parsing error with the line and column where it failed, instead of generating incorrect types from partial input.

Related reading