JSON TO TYPES GENERATOR · RUNS IN YOUR BROWSER

Turn JSON into TypeScript, Zod, JSON Schema or Go

Paste an API response, or several, and get types that match what the API really returns: optional fields found by merging samples, nullable fields, integers versus floats, dates, UUIDs, emails and URLs recognised, and identical nested shapes shared.

Nothing is uploaded. Your JSON stays in this tab and the page makes no network calls.

Your JSON

One value, several samples one per line (NDJSON), or several objects pasted back to back. More samples means better optional and nullable detection.

Paste JSON and click Generate.

Run it on files from the command line

node cli.mjs response.json                       # TypeScript
node cli.mjs a.json b.json c.json --style zod    # merge three samples
cat samples.ndjson | node cli.mjs --style go --name ApiResponse
node cli.mjs data.json --style jsonschema --readonly

Get cli.mjs and types.mjs from the repo. Node 18+, no dependencies.

Common questions

How do I generate TypeScript types from JSON?

Paste a JSON response, or several samples, and pick TypeScript. The tool reads every sample, merges them, and writes one interface per object shape. Fields missing from some samples become optional, fields that are sometimes null become nullable, and strings that are always dates, UUIDs, emails or URLs are annotated.

Why paste more than one sample?

One sample cannot show which fields are optional or which values can be null, so every field comes out required. Paste several responses one after another, or one per line, and the merged types reflect what the API actually returns.

Which output formats are supported?

TypeScript interfaces, Zod schemas with inferred types, JSON Schema (draft 2020-12), and Go structs with json tags. All four come from the same inferred model.

Does this upload my JSON?

No. Everything runs in this page and the page makes no network calls, so API responses containing customer data stay on your device. The CLI reads files or stdin on your machine and prints to your terminal.

How is this different from quicktype or json2ts?

It overlaps on purpose. It merges many samples, reports what it had to guess, and needs no install, account or upload. For a build-time pipeline use a maintained generator; use this to get a correct first draft in seconds.

More: how to type an API response safely (and why generated types lie)