JSON to TypeScript Interface Generator
Paste any JSON and get clean TypeScript interfaces — nested objects become their own interfaces, arrays are typed from their contents, and optional detection is automatic for null values. Everything runs locally.
How it works: the generator walks your JSON structure, creates an interface for every object (including nested ones), and infers types from values: string, number, boolean, typed arrays like Item[], and null becomes any | null.
Why generate interfaces instead of writing them by hand?
API responses are where TypeScript projects accumulate any types — hand-typing a 40-field response is tedious, so it gets skipped. Pasting a real response here produces accurate interfaces in seconds, including nested structures like user.address.geo becoming their own named interfaces. Fields that are null in your sample are marked optional, since a null in one response usually means sometimes-absent.
Frequently asked questions
Does this handle nested JSON objects and arrays?
Yes. Every nested object becomes its own named interface, and arrays are typed from their contents — an array of objects produces an interface plus an Item[] type, and mixed arrays produce union types like (string | number)[].
Is my JSON uploaded anywhere?
No. The conversion runs entirely in your browser with JavaScript. Your JSON — which often contains real API data — never leaves your device.
What is the difference between an interface and a type alias?
For object shapes they are mostly interchangeable. Interfaces can be extended and merged, which suits API models; type aliases handle unions and primitives. This tool emits interfaces for objects and type aliases only for top-level arrays and primitives.
How are null values typed?
A field that is null in your sample is emitted as optional (with ?) and typed any, because a single sample cannot reveal the real type. Replace any with the correct type when you know it — or paste a sample where the field has a value.