Developer
Encoders, converters & dev utilities
JSON to TypeScript Interface Generator
Turn a sample JSON object into a TypeScript interface, so you get compile-time types for an API response or config without hand-writing them. The generator infers each property's type from its value — numbers become number, text becomes string, true/false become boolean, null becomes null — and recurses into nested objects as inline object-literal types. Arrays infer their element type from the first item (an empty array becomes unknown[]). So {"id":1,"name":"Ada"} yields export interface Root { id: number; name: string }. JSON is parsed per RFC 8259 and the output is valid TypeScript you can paste straight into an .ts file. Runs 100% in your browser — your payload never leaves the page. Free, no login.
Infers property types from values: number→number, string→string, true/false→boolean, null→null
- Worked example — {"id":1,"name":"Ada"} → export interface Root { id: number; name: string }
- Nested objects become inline object-literal types; arrays infer element type from the first item
- Empty arrays fall back to unknown[]; the root interface name defaults to Root (configurable)
- JSON parsed per RFC 8259; 100% client-side — your sample payload never leaves the browser
Frequently asked questions
How do I generate a TypeScript interface from JSON?
Paste a representative JSON object and the tool infers an interface from it. Each key becomes a property whose type is read from the value: {"id":1,"name":"Ada","active":true} produces export interface Root { id: number; name: string; active: boolean }. Nested objects become inline object types and arrays infer their element type from the first element. Copy the result straight into a .ts file — the whole thing runs in your browser.
How does it type arrays and null values?
An array's element type is inferred from its first item, so ["a","b"] becomes string[] and [{"id":1}] becomes { id: number }[]. An empty array becomes unknown[] because there is no sample element to inspect. A JSON null becomes the TypeScript type null. Since a single sample can only show one shape, review optional or union fields (properties that are sometimes absent or of mixed type) and adjust the generated interface where your real data varies.
Is the inferred interface always exactly right?
It is exactly right for the sample you paste, but a single example cannot reveal every case. Fields that are optional, nullable, or hold mixed types across records will only reflect the one value in your sample, so you may need to add ? for optional keys or union types (string | null) by hand. The generator gives you an accurate, ready-to-edit starting point rather than a guess at your full schema.