Dad’s Data formats tools

JSON → TypeScript

Generate TypeScript interfaces from JSON — nested types, unions, and optional fields. 100% local.

JSON Input
Root type name
TypeScript Output
Paste JSON to generate TypeScript interfaces.

How Type Inference Works

The inferrer samples your JSON and produces the most specific TypeScript interface it can. Each key becomes a property. The value's runtime type determines the TypeScript type. For fields that are null in your sample, the inferrer produces T | null — meaning the field exists but may be null.

Input
{
  "user": {
    "id": 1,
    "name": "Alice",
    "email": "[email protected]",
    "role": "admin",
    "tags": ["typescript", "json"],
    "address": {
      "city": "London",
      "country": "UK"
    },
    "metadata": null
  },
  "total": 42,
  "active": true
}
Output
export interface Root {
  user: User;
  total: number;
  active: boolean;
}

export interface User {
  id: number;
  name: string;
  email: string;
  role: string;
  tags: string[];
  address: Address;
  metadata: null;
}

export interface Address {
  city: string;
  country: string;
}

Inference Rules

JSON valueTypeScript typeNotes
"string"stringAny string value
42 or 3.14numberAll JSON numbers become number
true / falsebooleanBoolean literal becomes boolean
nullnullNullable — combine with | T if field also has non-null values
[1, 2, 3]number[]Homogeneous array infers element type
[1, "a", true](number | string | boolean)[]Mixed array becomes union
{} or { ... }Named interfaceNested objects become separate interfaces
[] (empty)unknown[]Empty array can't be inferred — annotate manually
Tip: The root type name (configurable in the toolbar) becomes the name of the outermost interface. Nested objects are named by capitalizing their key name. For production code, review and adjust names like Address or User to match your domain model.

Limitations to Know

Warning: Inference is based on a single sample. If a field is null in your sample but is sometimes a string in real data, you'll need to manually change null to string | null. Run the inferrer on a representative sample that covers all the shapes your data can take.

Try It

Interactive — edit the input to see the output update
Try it
Result

Frequently Asked Questions

Your files stay on your computer. Dad promised.

Data formats tools

Search the Data formats tools