JSON to TypeScript Interfaces
Convert JSON data into TypeScript interface definitions with nested object and array type inference
About JSON to TypeScript
TypeScript adds static typing to JavaScript. Converting JSON to TypeScript interfaces improves code completion, type checking, and refactoring.
Highlights
Automatic type inference (string, number, boolean, null)
Supports nested objects and arrays
Outputs either interface or type
Optional property marks
Union types for mixed arrays
Quick start
- Paste JSON and the tool parses automatically.
- Set the interface name and output options.
- Copy or download the generated TypeScript definitions.
Example
Input JSON
{'{'}
"name": "John",
"age": 30,
"isActive": true,
"address": {'{'}
"city": "Beijing",
"zipCode": "100000"
{'}'}
{'}'}TypeScript Output
export interface RootObject {
name: string;
age: number;
isActive: boolean;
address: Address;
}
export interface Address {
city: string;
zipCode: string;
}Notes
- Arrays infer element types and generate related interfaces.
- Invalid property names are quoted to keep the types valid.