JSON to TypeScript Converter
Paste a sample response and get interfaces that actually match every item.
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 (user → User), 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
- Paste a sample response — a real one, with the fields that actually vary.
- Name the root type if you want something other than
Root. - 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?
Why is my id typed bigint?
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?
Does it handle unions and null?
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.