JSON to TypeScript Converter

Paste a sample response and get interfaces that actually match every item.

JSON sample
TypeScript interfaces

About this tool

Generate TypeScript interfaces from a JSON sample. Every array member is considered: objects with the same shape share one interface, keys missing from some members become optional (?), and genuinely different shapes become a union — so the types actually match your data, not just its first element.

Nested objects get their own named interfaces, named after the field they sit in (userUser), deduplicated by shape. The root object becomes the type you name it.

Integers beyond 2⁵³−1 are typed bigint, because number would round them — the same promise the rest of the site makes, applied to your types.

How to use it

  1. Paste a sample response — a real one, with the fields that actually vary.
  2. Name the root type if you want something other than Root.
  3. Copy the interfaces into your project. Optional fields are marked; nested shapes are named.

Worked example

The sample generates a Root interface with users: User[] and total: number — and User marks title optional, because only the second member has it. That is the whole point of this tool.

export interface Root {
  users: User[];
  total: number;
}

export interface User {
  name: string;
  email: string;
  title?: string;
}

One array, every member considered

Frequently asked questions

How does it merge array members?
Objects in one array that share a shape become one interface. When members differ, the merged interface marks keys missing from some of them optional and unions keys with conflicting types — the honest type for heterogeneous data.
Why is my id typed bigint?
Because it is a 19-digit integer, larger than a JavaScript number can hold exactly. Typing it number would make the type lie about your data. Keep it bigint, or store such ids as strings in the source data.
Can it generate types instead of interfaces?
The root of a scalar or array sample becomes a type alias; objects become interfaces because they extend well. For a single flat shape the difference is cosmetic — an interface compiles identically.
Does it handle unions and null?
Yes: a field that is sometimes null gets T | null, and an array holding different scalar kinds unions them. What it will not do is invent a type for a value that was never in the sample.
Is my data uploaded anywhere?
No. Generation runs locally; a dropped file is read in the tab and never leaves it.