JSON to TypeScript Interface Generator

Paste JSON, get TypeScript code instantly. Private, in your browser.

Input

Output

Ready
Ln 1, Col 1

Convert JSON to TypeScript in one step

Paste an API response or config file and get TypeScript interfaces that describe it, so your editor can autocomplete and type-check the data instead of treating it as any.

How to use it

  1. Paste a JSON sample into the Input panel, open a file, or drop it onto the page. A sample is already loaded so you can see the result.
  2. The TypeScript code appears instantly in the Output panel and updates as you type.
  3. Rename the top-level type under Settings → Root type name, and use Sort keys to order fields alphabetically.
  4. Copy the code or Download it as Root.ts.

What the TypeScript generator produces

  • An export interface for every object shape; nested objects get their own named interface (for example users becomes User).
  • Keys missing from some array items become optional with ?.
  • Mixed arrays become union types such as (string | number)[].
  • Keys that are not valid identifiers are quoted; identical shapes are reused instead of duplicated.

Using the generated TypeScript code

Save the interfaces to a file and use them to type parsed data:

import type { Root } from './types';

const res = await fetch('/api/data');
const data: Root = await res.json();
console.log(data.users[0].name);

More JSON tools

All tools are free and run privately in your browser.

JSON to TypeScript FAQ

Does it generate types or interfaces?

Interfaces for every object, plus a type alias when the top-level value is an array or a primitive.

How are optional properties detected?

If a key appears in some objects of an array but not in others, it is marked optional with ?. Values that are sometimes null get a | null union.

Is my data uploaded to a server?

No. The JSON to TypeScript runs entirely in your browser using JavaScript. Your data is never uploaded, logged or stored, and the tool keeps working offline after your first visit.