OpenAPI → Zod Generator — Docs

Quick start

Paste an OpenAPI spec and press Generate. That's the whole product.

Web

No install, nothing leaves your browser:

open https://openapi-zod-generator.pages.dev

CLI

Zero dependencies, works offline:

npx openapi-zod-gen ./openapi.yaml

The web tool

Getting your spec in

  • • Paste YAML or JSON directly
  • • Upload — the ⬆ button accepts .yaml / .yml / .json
  • • Drag & drop a file onto the input panel
  • • Share links — 🔗 compresses your spec into the URL; opening such a link auto-generates

Output options

React Hook FormzodResolver for every schema — forms enforce the same rules as your APIdefault: on
TanStack Querytyped useQuery / useMutation per operation, path params handleddefault: on
MSW Handlersmock endpoints with faker-driven responsesdefault: off
Fakertest-data factories per schemadefault: off
Strict Modeobjects emit .strict() — unknown keys rejected (off = OpenAPI default)default: on

Working with results

Each tab is a ready-to-paste file with its import headers. Copy per tab, download per tab, or Download all for a ZIP of every file. After each generation you get a stats line (schemas · operations · ms). Press Ctrl + ↵ anywhere to regenerate.

The CLI — openapi-zod-gen

npm i -g openapi-zod-gen openapi-zod-gen ./openapi.yaml -o ./src/generated --all

Generate

-o, --output <dir>output directory (default ./generated)
--allevery output file (adds MSW handlers + Faker factories)
--msw / --fakerenable those outputs individually
--no-strictpermissive objects (OpenAPI default)
--stdoutprint files instead of writing
--watchregenerate whenever the spec changes

Breaking-change detection

openapi-zod-gen diff ./specs/v1.yaml ./specs/v2.yaml --license PRO-xxxxxxxx-xxxx

Classifies every difference as breaking, compatible, or added — removed schemas/properties/endpoints, type changes, enum shrinkage, newly-required fields, tightened constraints, nullable regressions. Exit code 1 when breaking changes exist → CI-ready.--json for machines, --no-fail to always exit 0. Without a license, diff runs in preview mode (counts, first finding, exit codes).

OpenAPI compatibility

Both 3.0.x and 3.1 are supported. What the generator preserves:

oneOf / anyOf + discriminatorreal z.discriminatedUnion() — not a lossy z.union()
allOf: [$ref base, inline extension]merged into a single clean z.object
Circular $refsz.lazy() — no stack overflows
Formatsuuid, email, date-time, date, time, uri, ipv4, ipv6, regex patterns
Constraintsmin/max, lengths, items, multipleOf, uniqueItems, pattern
3.0 nullable: true.nullable()
3.1 type: ["string", "null"].nullable()
enum / constz.enum() / z.literal()
default / description.default() / .describe()
additionalPropertiesfalse → .strict(), schema → .catchall()/typed z.record()

Pro & licensing

Free forever

  • • All 6 generator outputs
  • • Diff summaries + CI exit codes
  • • The entire web tool

Pro — $39 one-time

  • • Full human-readable diff report
  • • Machine-readable JSON output
  • • Lifetime updates, priority support

Pay with USDT (BEP-20) — address and QR on the Get Pro page. Send 39 USDT on the BNB Smart Chain, email your TXID, receive a PRO-xxxxxxxx-xxxx key within 24h. Keys validate entirely offline — no account, works in air-gapped CI:

openapi-zod-gen diff old.yaml new.yaml --license PRO-xxxxxxxx-xxxx # or set once:  export OPENAPI_ZOD_GEN_LICENSE=PRO-xxxxxxxx-xxxx

FAQ

Is my spec uploaded anywhere?

No. The web tool is 100% client-side and the CLI is offline. Shareable links put the compressed spec in the URL itself — there is no server.

Is it really free?

The web tool and the CLI generation are free forever. Only the detailed diff report is Pro.

Is it open source?

Yes — MIT. github.com/Vaultshope/openapi-zod-generator. 57 unit tests, E2E-verified against the deployed site.

Does one license cover my whole team/machines?

Offline keys have no activation limit — use yours on any machine, including CI runners. Please buy one per engineer as a courtesy.

Which browsers work?

Any modern browser (Chrome, Edge, Firefox, Safari). Mobile fully supported.

Troubleshooting

"Invalid YAML at line X, column Y"

Fix the spec at that exact position — the parser reports where it stopped. JSON input works too if YAML keeps fighting you.

"missing required fields (openapi, info, paths)"

The file parsed but isn’t an OpenAPI document — it needs the openapi version, info and paths top-level keys.

"invalid license key (expected format: PRO-xxxxxxxx-xxxx)"

Check for typos and stray spaces. Set it via --license or the OPENAPI_ZOD_GEN_LICENSE environment variable.

Sent USDT on the wrong network

Crypto transfers are irreversible — funds sent on non-BEP-20 networks cannot be recovered. Always confirm BEP-20 before sending.

Found a generation bug

Open an issue on GitHub with your spec — real-world specs that break the generator are exactly what the project wants.