JSON to TypeScript

Generate TypeScript interfaces, Zod schemas and Python dataclasses from any JSON sample — powered by quicktype, running entirely in your browser.

JSON Input

Generation Options

Generated Code

Regenerates automatically as you edit the JSON, the type name or the target language.

About type inference:

Inference is powered by quicktype (MIT): nested objects become their own types, heterogeneous arrays become unions, and null becomes optional where the target language supports it. Everything runs in your browser — the JSON never leaves your machine.

How to Use the Tool

Paste a sample of the JSON your API returns and get strongly-typed code you can paste straight into your project — no more hand-writing interfaces to match backend payloads.

  1. Paste your JSON: A representative sample works best: include optional fields (as null) and array items so inference sees every shape.
  2. Name the root type: The name is sanitized to a valid identifier and PascalCased — "order response" becomes OrderResponse.
  3. Pick the target: TypeScript interfaces for types, Zod schema for runtime validation, Python dataclasses for backend models.
  4. Copy or download: Copy to clipboard or download as a ready-to-use file (types.ts, schema.ts or models.py).

Frequently Asked Questions (FAQ)

How are optional and nullable fields handled?

A field present with null in the sample generates a nullable type in TypeScript (string | null) and an Optional in Python. Fields entirely absent from the sample cannot be inferred — include them explicitly if you need them.

What happens with heterogeneous arrays?

Arrays mixing types generate union element types (e.g. (string | number)[]). If the mix is really a variant list, consider tagging the variants in your source data so each shape is distinguishable.

Why Zod instead of plain interfaces?

Interfaces are compile-time only. Zod schemas validate data at runtime — ideal for API boundaries, env vars and form input — and infer the static type for free with z.infer.

Is my JSON sent to a server?

No. The quicktype engine compiles to JavaScript and runs in your browser. Nothing is transmitted, logged or stored.

Share this tool