JSON to TypeScript
Generate TypeScript interfaces from JSON data
How to Use
- Enter JSON
Paste JSON data into the input area. Objects or arrays of objects are accepted.
- Convert
Click "Convert" to generate TypeScript interface definitions from the JSON structure.
- Copy result
Use the "Copy" button to copy the generated TypeScript definitions to your clipboard.
JSON to TypeScript Examples
Simple object
{
"id": 1,
"name": "John",
"active": true
}export interface Root {
id: number;
name: string;
active: boolean;
}Primitive types (string, number, boolean) are automatically inferred.
Nested object
{
"user": {
"name": "Jane",
"age": 25
},
"tags": ["dev"]
}export interface Root {
user: User;
tags: string[];
}
export interface User {
name: string;
age: number;
}Nested objects are generated as separate interfaces.
Features
- Auto-generate TypeScript interfaces from JSON
- Recursive type inference for nested objects and arrays
- Optional fields (?) from null values
- Union type inference for mixed-type arrays
- Customizable root interface name
- Toggle export modifier on/off
- Local processing (your input is not sent to servers)
FAQ
How are null values handled?
Fields with null values are marked as optional (?) with type "unknown". In arrays with other values, null creates a union type.
What if an array contains different types?
All element types in an array are inspected and combined into a union type (e.g., string | number) if multiple types exist.
Is my data sent to a server?
No. All type generation happens locally in your browser via JavaScript. Your input data is never transmitted to any external server.