# 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.

## 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.

Your ad here?

[Email us](mailto:hi@dennn.is?subject=Advertising%20on%20OneClick%20Pro)

[Ad 433 tools for your AI agents through one MCP server.](https://multitaskai.com/?ref=oneclickpro)
