OpenAPI to Zod converter

Convert OpenAPI to Zod 4 schemas: paste an OpenAPI 3.0/3.1 or Swagger 2.0 spec and get a schema for every component, request and response, ready to validate API traffic.

OpenAPI

Zod

Waiting for input

What you get

How each result is checked

  1. Every schema is read from the document and compiled with Ajv, the reference JSON Schema validator.
  2. The generated Zod code is run, and every schema must build.
  3. For every schema, Zod and Ajv validate the same test values (including the spec's examples) and must agree on each one.

What can't convert exactly

  • Formats such as email and date-time use Zod's own checks, which differ from other validators on rare edge cases. Choose "Ignore" to treat them as annotations.
  • OpenAPI number formats (int32, int64, float, double) are type hints and are not turned into range checks.
  • "discriminator" is a hint for code generators. Validation follows the oneOf/anyOf branches, which gives the same result for well-formed specs.

Questions

Does it handle allOf composition?

Yes, and exactly: every part must pass on its own, as in JSON Schema. That includes strict parts with additionalProperties: false.

How fast is it on large specs?

Specs of a few hundred kilobytes convert and verify in a couple of seconds in your browser.

Can I convert Swagger to Zod?

Yes. Swagger 2.0 documents work the same way as OpenAPI 3.0 and 3.1, in YAML or JSON.

Which OpenAPI versions work?

OpenAPI 3.0, OpenAPI 3.1 and Swagger 2.0, in YAML or JSON. Each component schema, request body and response becomes a Zod 4 schema with its TypeScript type.

How do I convert OpenAPI to Zod online?

Paste your OpenAPI or open a file on the left (or click Example). The Zod appears on the right as you type, already checked. Copy it, or download it as a file. Nothing is uploaded.

Can the Zod output be wrong?

Every result is checked before it is shown (the checks are listed on this page). If a check fails, the page says "Review needed" and why, instead of presenting the output as correct, and anything that cannot convert exactly is named in the notes.