Convertful
ImagePDFVideoUtilityBlog

Image Tools

  • Compress Image
  • Resize Image
  • Remove Background
  • HEIC to JPG
  • All Image Tools →

PDF Tools

  • Compress PDF
  • Merge PDFs
  • Split PDF
  • PDF to Images
  • All PDF Tools →

Video & Audio

  • Video to GIF
  • Compress Video
  • Trim Video
  • Extract Audio
  • All Video Tools →

Utility

  • QR Code Generator
  • JSON Formatter
  • Color Converter
  • All Utility Tools →
All processing happens in your browser. Your files never leave your device.
AboutBlogTermsPrivacyContact
© 2026 Convertful. All rights reserved.
HomeUtilityJSON to TypeScript

JSON to TypeScript Interface Generator

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.

Settings

Paste JSON above to generate TypeScript types.

You might also need

JSON to Go StructGenerate Go structs with JSON tags from a sample
JSON to Python Dataclass / TypedDictGenerate @dataclass or TypedDict classes from JSON
JSON FormatterFormat and validate JSON data
JSON Diff CheckerCompare two JSON documents semantically

From API Sample To Typed Code In One Paste

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.

Type Inference Decisions The Tool Makes

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.

Why Not Quicktype?

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.

Export, Readonly, Root Name

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.

FAQ

How does it handle nested objects?

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.

What about null values?

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.

Does it use quicktype?

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.

Can I export the interfaces?

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.