JSON to TypeScript
Generate type definitions from JSON for TypeScript, Go, Rust, Python, Java, and C#.
Free & unlimited
Language
Declaration
Input JSON
TypeScript output
export interface Root {
id: number;
name: string;
tags: string[];
active: boolean;
}All processing happens in your browser. No data is sent to any server.
About this tool
- 1
Paste your JSON
Enter a JSON object or array that represents the data structure you want to type.
- 2
Set the root type name
Give the top-level TypeScript interface a descriptive name (e.g., "UserResponse").
- 3
Review the interfaces
Check the generated TypeScript interfaces for correctness, especially nested types and arrays.
- 4
Copy to your project
Copy the TypeScript definitions and paste them into your .ts or .d.ts file.
- Use descriptive root type names - they become the main interface name in the generated code.
- Null values generate "null | unknown" types; replace "unknown" with the actual type manually.
- Nested objects automatically get their own named interfaces for reusability.
- If an array contains mixed types, the generator creates a union type for the array items.
- Generates TypeScript interfaces with proper nesting
- Handles arrays, nested objects, and primitive types
- Creates separate named interfaces for nested structures
- Supports optional fields when analyzing multiple JSON samples
- Clean output ready to paste into TypeScript projects
- Generate TypeScript types from API response JSON to ensure type safety in frontend code
- Create type definitions for JSON configuration files used in TypeScript projects
- Bootstrap interfaces from database query results for ORM models
- Type API request bodies to catch payload errors at compile time
It generates interfaces by default, which is the recommended approach for object shapes in TypeScript. You can switch to type aliases in the settings.
When you provide multiple JSON samples, fields that appear in some but not all samples are marked as optional with the ? modifier.
Yes. Nested arrays of objects get their own named interface, and the array type references it (e.g., items: Item[]).