🔨 JSON to TypeScript Converter
Generate TypeScript interfaces and types from JSON data. Runs in your browser.
Last updated: November 8, 2026 · By the BoltQuickTools team
Turning a sample response into TypeScript types
You have a real API response and need a first draft of its types without typing every field by hand. This page reads one JSON sample and writes matching interfaces or type aliases. Because it only sees that one sample, treat the output as a draft to review.
Settings above the panels
Paste into JSON Input. Output in TypeScript Output updates shortly after you stop typing, and immediately on paste or when you press Convert.
- Root name sets the top-level type. It defaults to Root.
- Style chooses
interfaceortype. - Indent is 2 or 4 spaces.
- Optional properties adds
?to every field. - Export keyword adds or removes
export. - Format JSON tidies the input, Load Sample loads an example, and Copy TypeScript copies the result.
From sample response to interfaces
{"id":7,"name":"Ada","created_at":"2026-03-01T09:00:00Z","nick":null,
"home_address":{"city":"Oslo"},"tags":["a","b"],
"orders":[{"sku":"A1","qty":2},{"sku":"B2","gift":true}]}
generates:
export interface HomeAddress {
city: string;
}
export interface Orders {
sku: string;
qty: number;
gift: boolean;
}
export interface Root {
id: number;
name: string;
created_at: string; // ISO date string;
nick: null;
home_address: HomeAddress;
tags: string[];
orders: Orders[];
}
Child types come first and the root type last. Look at Orders: the second order had no qty and the first had no gift, yet both are required in the output.
What to fix by hand
- Fields missing from some array items are not marked optional. Keys are merged across items but no
?is added unless you tick Optional properties, and that applies to every field in the file. - The first value decides a merged key's type.
[{"v":1},{"v":"s"}]givesv: number, not a union. Unions are produced only for values directly inside one array, as in(number | string | null | boolean)[]. nullbecomes the typenull, and an empty array becomesany[], because the sample cannot say more. Replace them with real types such asstring | null.- Names are not singularised, so an
ordersarray yieldsOrders[]. You will probably want to rename itOrder. - Acronyms lose their capitals: a key
URLPathgivesUrlpath, and a root name ofAPIResponsegivesApiresponse. - A nested key that matches the root name produces two declarations named
Root. As interfaces they merge without warning, and with Style set to type they are a compile error. - Keys that start with a digit or symbol get an invalid type name.
"3d"and"@type"produceinterface 3dandinterface @type, which do not compile. The property itself is quoted correctly. - Date-like strings stay
stringand gain a comment, which ends with a stray semicolon. The check is by pattern only, so2026-13-45is flagged too. - A bare value or an array of plain values at the root gives only a comment, such as
// Root is an array: (number | string)[].
Using the generated types
Should I choose interface or type here?
For this output the only practical difference is how duplicates behave, as noted above. Follow your project's convention. TypeScript tips covers refining generated types, including nullable and optional fields.
Can it give me runtime validation?
No, the output is compile-time types only. To check real data, write a schema and test with the JSON Schema Validator.
Should I paste one record or many?
Put several varied records in one array. Key merging only sees what you paste, so a fuller sample finds more fields. Types for repeated keys still come from their first appearance.
If you already have a schema, the JSON Schema to Code Generator works from that instead of a sample.