JSON to TypeScript
Infer TypeScript interfaces from a sample JSON value, live as you type.
interface Root {
id: number;
name: string;
active: boolean;
tags: string[];
}Infers TypeScript interfaces from a sample JSON value, live as you type โ one interface per nested object shape. Since it only sees one sample, it can't know if a field is ever optional or a union of types; review the output before using it. Runs entirely in your browser.
Need the opposite? JSON to XML Converter
What is JSON to TypeScript?
Paste a sample JSON value (an API response, a config object) and get inferred TypeScript interfaces instantly, one interface per nested object shape, saving the tedium of hand-writing types for a large response. A fast starting point when integrating a new API: paste one real response and get a typed shape to work against immediately, instead of hand-writing an interface field by field. Inference happens live in your browser as you type.
How to Use JSON to TypeScript
- 1
Paste a Sample JSON Value: Enter a real API response or config object.
- 2
Read the Inferred Interfaces Instantly: TypeScript interfaces appear automatically, one per nested object shape.
- 3
Copy and Refine: Copy the result into your codebase and adjust for optionality or unions your API may actually have.
How the Mapping Works
Each JSON object's keys become interface properties, and each value's JSON type is mapped to its TypeScript equivalent: a string stays string, a number stays number, a boolean stays boolean, and null becomes null. A nested object gets its own named interface, referenced by the parent property's type, rather than being inlined.
Example
Input:
{ "id": 1, "name": "Alice", "active": true, "address": { "city": "Boston" } }
Output:
interface Address {
city: string;
}
interface Root {
id: number;
name: string;
active: boolean;
address: Address;
}
The nested "address" object gets its own Address interface, referenced from the root interface's address property.Frequently Asked Questions
Common questions about JSON to TypeScript.