Skip to content

JSON Schema to Zod

Convert a JSON Schema into Zod schemas. Types, required properties, enums, const, anyOf, oneOf and allOf map to their Zod builders, and the common validation keywords such as minLength, maximum, pattern, format and minItems become Zod checks. Each definition becomes an exported schema with a z.infer type.

Reset

Frequently asked questions

Which validation keywords are converted?

minLength and maxLength become .min() and .max() on strings, pattern becomes .regex(), and the formats email, uri, uuid and date-time become .email(), .url(), .uuid() and .datetime(). minimum, maximum, exclusiveMinimum, exclusiveMaximum and multipleOf become number checks, and minItems and maxItems become array checks.

How are definitions ordered?

Every definition is declared before the schemas that use it. A definition that refers to itself, directly or through others, is referenced with z.lazy so the code still runs.

Do recursive schemas type-check?

They run, but TypeScript cannot infer the type of a schema that refers to itself through z.lazy. Add an explicit type annotation to such a schema, as the Zod documentation describes for recursive types.

How is additionalProperties handled?

additionalProperties false adds .strict(), a schema adds .catchall() with that schema, true adds .passthrough(), and an object with no properties but an additionalProperties schema becomes z.record(z.string(), ...).

Which Zod version does the code target?

The generated builders, such as z.object, z.union, z.record with a key schema and .nullable(), exist in Zod 3 and Zod 4. Zod 4 still accepts the string format methods such as .email(), although it also offers z.email() as a shorter form.

What happens to references the tool cannot resolve?

References outside the document, such as another file or a URL, become z.unknown() and are listed in a comment at the top of the output.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.