Generate TypeScript interfaces from a JSON sample. Free, private, runs in your browser.
100% private — your files never leave your browser. All processing happens locally on your device.
You're integrating with a new API. The docs are vague. You have one example response. You want strongly-typed code in your TypeScript project, not an `any` hole. Paste the JSON sample here, choose a root name, and you get a ready-to-use `interface` block that captures the shape — keys become fields, JSON types become TypeScript types, nested objects become named sub-interfaces. Fine-tune by hand where inference is ambiguous, then paste into your `src/` directory and go.
String values map to `string`. Numbers map to `number` (no int/float distinction — TypeScript doesn't make one either). Booleans map to `boolean`. Nulls map to the literal `null` type so you get a hard flag that a field can be null. Arrays emit an element-type array — homogeneous arrays become `T[]`, heterogeneous arrays become `(A | B)[]`. Nested objects become their own named interface. Empty arrays become `unknown[]` so downstream code is forced to narrow before use.
Quicktype is an excellent tool — it does multi-language generation, schema inference across multiple samples, and deep type unification. It's also ~300 KB gzipped. For the 90% case of single-sample TypeScript inference, we ship a custom lightweight inferencer that handles the common shapes: nested objects, arrays, unions, nullables, and reserved-word-safe field quoting. If your needs exceed what this tool offers — multi-sample unification, enum detection, JSON Schema output — quicktype is the right pick.
Three switches shape the output. `export` prefixes the keyword so the interface is importable from another file. `readonly` prefixes every field with the `readonly` modifier — useful for immutable data contracts passed through a Redux-style store or any place where accidental mutation is the enemy. `Root name` sets the top-level interface name; nested objects are named from their parent field. Combined, these cover the most common presentation choices without cluttering the UI.
Each unique object shape becomes its own named interface. Nested objects are named from the parent field (e.g., `address: Address` with an `Address` interface). Identical shapes reuse the same name; divergent shapes get numeric suffixes.
A null value emits `field: null`. If a field is present in some samples and absent in others (not supported from a single sample), mark it optional manually with `?:` — we don't infer optionality from one example.
No. Quicktype is ~300 KB and does far more than we need. This tool uses a custom lightweight inferencer that handles the 90% case — nested objects, unions, arrays, and nullables — in a fraction of the bundle size.
Yes. Toggle the `export` prefix, choose a root name, and copy or download the result. The output is ready to paste into a `.ts` file.