jsontoschema

JSON to TypeScript converter

Paste any JSON payload and get clean TypeScript interfaces. Nested objects become named types. Optional fields and unions are detected automatically.

How it works

Drop in a JSON response from any API. The converter walks the structure, extracts nested objects into named interfaces, infers types from values, and outputs valid TypeScript you can paste straight into your codebase.

JSON input
{
  "id": 1,
  "name": "Alice",
  "email": "alice@example.com",
  "verified": true,
  "address": {
    "city": "San Francisco",
    "zip": "94102"
  },
  "tags": ["admin", "user"]
}
TypeScript output
interface Address {
  city: string;
  zip: string;
}

interface Root {
  id: number;
  name: string;
  email: string;
  verified: boolean;
  address: Address;
  tags: string[];
}

Smart array merging

When your JSON contains arrays of objects, the converter inspects every item, merges their fields, and marks anything that doesn't appear in all items as optional. Mixed-type fields become unions.

Array with varying items
[
  { "id": 1, "name": "Deploy v2.4",
    "status": "completed",
    "error": null },
  { "id": 2, "name": "Deploy v2.5",
    "status": "failed",
    "error": "timeout",
    "retryCount": 3 }
]
Merged TypeScript
interface Root {
  id: number;
  name: string;
  status: string;
  error: string | null;
  retryCount?: number;
}

type RootList = Root[];

What you get

Named interfaces

Nested objects are extracted into their own interfaces. No inline anonymous types cluttering up your code.

Optional field detection

Fields that appear in some array items but not others are automatically marked with ?.

Union types

A field that's sometimes a string and sometimes null becomes string | null. The converter handles any mix of primitive types.

Runs in your browser

Nothing is sent to a server. Your JSON stays on your machine, and the conversion happens instantly.

Also available as a simplified schema

Need something lighter than full TypeScript interfaces? Switch to Schema mode in the tool for a compact, human-readable format that's ideal for LLM prompts, API docs, and quick comprehension. Same tool, same JSON input, different output.

Try it now

Paste your JSON and get TypeScript interfaces in one click. Switch between Schema and TypeScript mode anytime.