Skip to content
ToolMug

JSON to TypeScript Converter

Turn a JSON sample — an API response, a config file, a fixture — into TypeScript interfaces you can paste into your code. Nested objects get their own named types, and differences between array items become optional or union types.

Runs in your browser — nothing you enter is uploaded

How to use

  1. Paste a JSON sample, or click Load sample.
  2. Set the name of the root type.
  3. Choose interfaces or type aliases.
  4. Copy or download the generated types.

Options explained

Root type name
Name of the top-level type, for example User or ApiResponse. Nested types are named after their keys — address becomes Address, and items in posts become Post.
Use type instead of interface
Generates type aliases (type User = { … }) instead of interfaces. Both work the same for plain data.

Examples

{"id": 1, "tags": ["a"], "owner": {"name": "Ada"}} becomes:

export interface Owner {
  name: string;
}

export interface Root {
  id: number;
  tags: string[];
  owner: Owner;
}

Frequently asked questions

How are arrays of objects handled?

All items are merged into one type. A key that appears in only some items becomes optional (key?), and a value that is sometimes null becomes a union such as string | null.

Why is a field typed as unknown?

The sample only contained null for it, so its real type cannot be inferred. Replace unknown with the correct type, or paste a sample where the field has a value.

Are integers and decimals different types?

Not in TypeScript — both become number. The Go, Rust and Python outputs do distinguish them.

Is my JSON uploaded?

No. The types are generated in your browser, so API responses with real data stay on your device.

Privacy

This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.

Related tools