JSON → TypeScript
Generate TypeScript interfaces or type aliases from JSON. Handles nested objects, arrays, unions, and nullable types.
Root type name
JSON input
TypeScript output
interface Address {
street: string;
city: string;
zip: string;
}
interface Order {
id: number;
total: number;
items: string[];
}
interface Root {
id: number;
name: string;
email: string;
active: boolean;
address: Address;
tags: string[];
orders: Order[];
metadata: unknown | null;
}Was this page helpful?
Related tools
About JSON to TypeScript
Generate TypeScript interfaces or types from a sample JSON object, inferring field names and types automatically. Saves you from hand-writing types for API responses and keeps your code in sync with real payloads.
How to use
- Paste a representative JSON response into the input.
- Review the inferred interfaces, including nested objects and arrays.
- Copy the generated types into your codebase and adjust optionality where needed.
Frequently asked questions
- Does it infer optional fields?
- It infers types from the sample you provide; fields absent in some objects may need to be marked optional manually.
- Are nested objects supported?
- Yes — nested objects become their own interfaces and arrays are typed by their element type.