JSON to TypeScript
Generates TypeScript interfaces from a JSON sample. Nested objects become their own interfaces, arrays of records are merged so keys that appear in only some records are marked optional, and a field that is ever null is typed as a union with null. Paste a whole API response to type it in one step. Runs entirely in your browser — nothing is sent to a server.
Generates TypeScript interfaces from a JSON sample. Nested objects become their own interfaces, arrays of records are merged so keys that appear in only some records are marked optional, and a field that is ever null is typed as a union with null. Paste a whole API response to type it in one step. Runs entirely in your browser — nothing is sent to a server.
Use cases
- Typing an untyped API response without writing interfaces by hand
- Turning a JSON fixture into types for a new client SDK
Examples
Nested object
{"id":1,"name":"Ada","tags":["math"],"address":{"city":"London"}}export interface Root {
id: number;
name: string;
tags: string[];
address: Address;
}
export interface Address {
city: string;
}FAQ
Is my data sent to a server?
No — this tool runs entirely in your browser.
How are optional fields decided?
When the input is an array of objects, a key missing from any record is marked optional with "?". A key that is present but sometimes null is typed as a union with null instead.