How to convert JSON to a TypeScript interface
Generate TypeScript interfaces or types from a JSON sample instantly in your browser.
A JSON-to-TypeScript converter infers a type from a JSON sample: each key becomes a property and each value’s shape becomes its type (string, number, boolean, arrays, and nested interfaces). Paste your JSON and it generates ready-to-use interfaces.
Input
{ "id": 1, "name": "Ann", "active": true }Output
interface Root {
id: number;
name: string;
active: boolean;
}Nested objects become their own interfaces; arrays infer an element type like string[].
Open the JSON to TypeScript → Free · runs in your browser · nothing uploaded
Steps
- Open the JSON → TypeScript tool and paste a representative JSON sample.
- Read the generated interface(s) and copy them into your codebase.
- Provide a sample that includes every field (and realistic values) so types are inferred accurately.
- Rename the root interface to match your domain after pasting.
Frequently asked questions
- How are arrays typed?
- The element type is inferred from the array’s items — ["a","b"] becomes string[]. Mixed arrays widen to a union like (string | number)[]; empty arrays fall back to unknown[] or any[].