JSON to TypeScript Interface Generator
Paste JSON, get TypeScript interfaces. Handles nested objects, arrays, unions, optional fields. No signup, runs in your browser.
What this does
Paste any JSON, get TypeScript interfaces back. The generator walks the structure and emits one interface per nested object, with arrays typed as T[] (or (A | B)[] if elements vary) and primitives mapped to string, number, boolean, null, or unknown for empty arrays.
The generated interfaces are paste-ready — they use export interface by default so they drop straight into a .ts file. Toggle that off if you want plain interface declarations.
When type inference is good enough — and when it isn’t
A JSON sample shows you exactly the keys present in that one example. It can’t tell you:
- Which fields are sometimes missing from other API responses (use the “All fields optional” toggle if you know the API can omit any field)
- Which
nullvalues are actuallystring | nullornumber | null(use the “null → optional” toggle to mark them as?:instead of typing them as the literalnull) - Which numbers are integers vs floats (TypeScript uses
numberfor both anyway) - Which strings are constrained literals like
"active" | "inactive"
Real-world workflow: generate a draft from one JSON sample, then hand-tune. Add unions for status fields. Add optionals for keys you know are sometimes absent. Tighten string fields to literal unions where the API contract guarantees them.
Common use cases
- API client typing. Hit your endpoint once with curl, paste the response, get the interface to start typing your fetch wrapper.
- Migrating from JavaScript. Existing JSON fixtures become typed seed data.
- Quick sanity check. “Does my response shape match what the frontend expects?” Generate from both and diff.
- Documenting third-party APIs. Vendor docs are often incomplete; their actual response shape — once you see it — generates a more honest type than their PDF claims.
What it does NOT do
- Does not generate Zod or io-ts schemas (different tool — paste into
json-to-zod.comif you need runtime validation). - Does not infer literal-string unions.
"role": "admin"becomesrole: string, notrole: "admin". - Does not handle JSON Schema. If you have a JSON Schema document, use a json-schema-to-ts converter instead.
- Does not preserve key order across regenerations.
Privacy
The tool runs entirely in your browser. JSON never leaves your machine.