Overview
What it does
- • Auto-generates TypeScript interfaces from JSON.
- • Real-time conversion while typing/pasting.
- • Generates child interfaces for nested objects.
Input requirements
- • JSON must be valid and parseable.
- • Top-level array is supported but inferred from first item.
- • Mixed-type arrays may require manual edits.
Quick Start
- Open /json-to-typescript
- Paste JSON into the left editor
- Review generated interfaces in the right panel
- Copy or download
Type Mapping
Primitives
- • string → string
- • number → number (no int/float distinction)
- • boolean → boolean
- • null → null (consider refining manually)
Complex
- • array → T[] (inferred from first element)
- • object → Named child interface (e.g., AddressInterface)
- • nested object → Separate interface + field reference
Arrays & Nested Objects
Good Example
{
"users": [{ "id": 1, "name": "A" }]
}Needs Review
{
"values": [1, "two", true]
}Mixed types; adjust to a union or normalize data.
Example
Input JSON
{
"name": "Alice",
"age": 28,
"active": true,
"address": { "city": "Paris" },
"tags": ["dev", "ts"]
}
Generated Interfaces
interface RootObject {
name: string;
age: number;
active: boolean;
address: AddressInterface;
tags: string[];
}
interface AddressInterface {
city: string;
}Tips & Limitations
Recommended
- • Validate JSON before conversion
- • Rename interfaces to domain-specific names
- • Add optional modifiers (?) where appropriate
Limitations
- • Mixed arrays inferred from first element
- • No automatic optional/union detection
- • Complex schemas may need refinement