JSON Schema to Zod converter
Convert JSON Schema to Zod 4 schemas that accept exactly the same data as your schema: lengths, patterns, ranges, enums, unique items, tuples, $refs, patternProperties, not, if/then/else and dependencies included.
What you get
- A Zod schema from JSON Schema that accepts exactly the same data: oneOf (exactly one), not, if/then/else, dependencies and patternProperties included.
- Tested against Ajv, the reference JSON Schema validator, on every result.
- String lengths counted in characters, as JSON Schema does (an emoji is one).
- Zod 4 output with inferred TypeScript types.
How each result is checked
- Your schema is compiled with Ajv, the reference JSON Schema validator.
- The generated Zod code is run, and every schema must build.
- Ajv and the generated Zod schema validate the same set of test values and must agree on every one.
What can't convert exactly
- Formats like email and date-time use Zod's own checks, which differ from Ajv on rare edge cases (for example one-letter domain endings). Choose "Ignore" to treat formats as annotations, which is the JSON Schema default.
- "oneOf" is checked exactly: data must match exactly one branch, as JSON Schema requires (a plain Zod union would accept data matching several).
- String lengths count characters like JSON Schema does, so an emoji counts as one. You can switch to Zod's .min()/.max() instead.
- unevaluatedProperties, unevaluatedItems and $dynamicRef are not translated yet. When your schema uses them, the warning names them.
Questions
Why not just use .int() for integers?
Zod's .int() rejects whole numbers above 2^53, which JSON Schema accepts. The generated check accepts the same numbers as your schema.
How exact is it?
For every test schema, Zod and Ajv must agree on thousands of generated values and mutations of them (missing keys, wrong types, extra keys, edge-case strings and numbers).
Does the output work with Zod 3?
The output is written for Zod v4 (for example z.looseObject and the built-in string formats). Zod 3 does not have all of these, so upgrade to Zod 4 to use it as it is.
Do I need to install a package to convert JSON Schema to Zod?
Nothing to install: no package, CLI or account. It runs in your browser, so you can try a schema before adding a generator to your build.
How do I convert JSON Schema to Zod online?
Paste your JSON Schema 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.