How to Convert JSON to TypeScript Interfaces
TypeScript interfaces describe the shape of JSON you already have: an API body, a fixture, or a copied network-tab payload. This page uses the same inference this site runs in the browser, so the output matches the converter.
Start with a complete sample. Inference can only name fields that appear in the JSON you paste.
{
"id": 42,
"email": "[email protected]",
"active": true
}// Generated locally in your browser. No data was sent to a server.
export interface User {
id: number;
email: string;
active: boolean;
}
{ "title": "Notes", "published": false }// Generated locally in your browser. No data was sent to a server.
export interface Article {
title: string;
published: boolean;
}
Edge cases
- Invalid JSON (trailing commas, single quotes, unquoted keys) will not convert. Fix the payload or use Format JSON after it parses.
- A JSON primitive such as 3 or "ok" emits a type alias, not an interface, because there is no object shape to describe.
- Unicode and escaped strings are valid JSON string values; they still type as string.
Open the converter with your own payload when you want to copy or download the generated .ts file.