{ } Schemato

OpenAPI to Zod Converter

Paste a OpenAPI sample, get production-ready Zod code. Runs entirely in your browser.

Examples:

components.schemas.User in YAML form

InputOpenAPI
OutputZod

About this converter

Pair runtime validation with your OpenAPI contract. Useful for catching backend changes before they crash the front-end.

Why convert OpenAPI to Zod

  • Validate API responses at the boundary so bad data never reaches your business logic.
  • Get TypeScript types and runtime checks from a single source of truth.
  • Catch shape regressions in CI by running schemas against fixtures.

How to use

  1. Paste your OpenAPI on the left panel, or pick one of the sample tabs above.
  2. The converter infers field names, optionality, and types automatically.
  3. Copy the generated Zod on the right and drop it straight into your codebase.

Common pitfalls

  • Inferred types reflect only the sample you paste. Real APIs may return null in fields that look non-null in your sample — widen with `.nullable()` if in doubt.
  • If your input has fields that are sometimes integers, sometimes floats, the inferred type will widen to `z.number()`. Add `.int()` back where you know the contract.
  • Empty arrays default to `z.array(z.unknown())`. Provide a non-empty sample to get a meaningful element type.

FAQ

Is this openapi to zod converter free?
Yes. It is fully free, no signup, and runs entirely in your browser. We do not store your input.
Does it work with nested objects and arrays?
Yes. Nested objects produce separate named types, and arrays infer the element type from the first non-null sample.
What about optional / nullable fields?
Fields whose value is null in the sample (or marked optional in JSON Schema / Prisma / GraphQL) are marked optional/nullable in the output. For real APIs, you may want to widen optionality manually after generation.
Can I generate Zod from multiple OpenAPI samples?
Today the tool processes a single sample. For more aggressive inference across multiple shapes, run the converter on the union/merge of your samples or open an issue.
Is the source code available?
Yes — the entire project is open source. See the GitHub link in the footer.

Related converters