JSON to TypeScript
Turn sample JSON into TypeScript interfaces or type aliases, with nested objects, arrays and optional fields inferred.
No uploads
export interface Root {
id: number;
name: string;
email: string;
active: boolean;
tags: string[];
address: Address;
orders: Order[];
}
export interface Order {
id: string;
total: number;
coupon?: string;
}
export interface Address {
city: string;
zip: null;
} How to use JSON to TypeScript
- 1Open JSON to TypeScript. It runs in your browser, no sign-up.
- 2Type or paste your input.
- 3Copy or download the result.
Questions
How are optional fields detected?
When an array contains objects and a key is missing from some of them, that key is marked optional with ?.
What about null values?
null is kept in a union, e.g. string | null, so you can see which fields can be empty.
Is my JSON uploaded?
No — conversion happens entirely in your browser.
More tools
JSON Formatter & ValidatorPretty-print, minify, validate Base64 Encoder & DecoderText and files Hash GeneratorMD5, SHA-1, SHA-256, SHA-512 Password & UUID GeneratorStrong, random, local Regex TesterLive matches and groups JWT DecoderHeader, payload, expiry Diff CheckerCompare two texts CSV ↔ JSON ↔ YAML ↔ XMLConvert data formats