JSON to TypeScript Converter
Generate TypeScript interfaces and types from JSON data instantly. Handles nested objects, arrays, nulls, and complex structures.
Left Panel
Right Panel
How to Use
- Paste your JSON data or click “Sample” to load example data.
- Configure options: root name, interface vs type, readonly, export, optional nulls.
- TypeScript interfaces are generated instantly in the right panel.
- Copy to clipboard or download as a
.tsfile.
Features
Nested Object Support
Nested JSON objects are extracted into separate named interfaces with proper references.
Array Type Inference
Arrays are typed based on their contents. Mixed-type arrays produce union types automatically.
Interface vs Type
Choose between TypeScript interfaces (declaration merging) or type aliases.
Readonly & Optional
Mark all properties as readonly, and automatically make nullable fields optional.
Related Tools
Related Guides
TypeScript & JSON — Type Safety with Zod & io-ts
Bridge the gap between JSON and TypeScript with type guards, Zod schemas, and runtime validation.
JSON Schema — Validate API Data Like a Pro
Learn JSON Schema from scratch: define types, required fields, patterns, and validate API payloads.
JSON Serialization Edge Cases
Master the types that JSON.stringify breaks: Date, BigInt, undefined, NaN, Set, Map, and circular references.
Frequently Asked Questions
How does JSON to TypeScript conversion work?
The tool parses your JSON, infers TypeScript types from the values (strings → string, numbers → number, objects → interfaces, arrays → typed arrays), and generates clean TypeScript interfaces or type aliases. Nested objects become separate named interfaces.
Does it handle arrays with mixed types?
Yes. When array items have different shapes (e.g., some objects have extra fields), the tool creates union types or optional properties to represent all possible item structures accurately.
Should I use "interface" or "type"?
Interfaces are preferred for object shapes because they support declaration merging and are more readable. Types are useful when you need union types, mapped types, or conditional types. The default is interface.
What does "optional nulls" do?
When enabled, any property whose value is null in the JSON will be marked as optional (?) in TypeScript. This is the most common pattern since null usually means "this field may not be present."
Can I customize the root type name?
Yes. Enter any PascalCase name in the "Root name" input. Nested types are automatically derived from property names (e.g., an "address" property generates an "Address" interface).
Is my data uploaded to a server?
No. All conversion happens entirely in your browser. Your JSON data never leaves your machine.