How to convert a schema to Zod
- Paste a JSON Schema on the left, open a file, or load one from your stash.
- Choose the options. The Zod code updates as you type.
- Copy it into your project or download it as a
.tsfile, thennpm install zodif you have not already.
Strings get .min(), .max(), .regex() and format checks such as .email(), .url(), .uuid(), .date() and .datetime(). Numbers get .int(), .gte(), .lt() and .multipleOf(). Optional properties get .optional(), additionalProperties: false becomes .strict(), and enums become z.enum() or literal unions.
Options
- Export inferred types
- Adds
export type User = z.infer<typeof UserSchema>after each schema. - .describe() from descriptions
- Keeps each
descriptionas Zod metadata, which tools that turn Zod into JSON Schema or OpenAPI can read back.
FAQ
Which Zod versions does the output support?
The generated code only uses APIs available in both Zod 3.23+ and Zod 4, such as z.string().email(), .datetime({ offset: true }), z.record(z.string(), …) and .catchall(). Some of them are marked deprecated in Zod 4 but still work.
How are recursive schemas handled?
Schemas are declared in dependency order. When definitions refer to each other in a cycle, references use z.lazy() and the cycle gets an explicit TypeScript type, because Zod cannot infer recursive types on its own.
Is anything approximated?
A few keywords have no direct Zod equivalent: patternProperties become .catchall() (or a record with a key pattern), uniqueItems becomes a refine() check, and not, if/then/else and minProperties are skipped. Notes appear under the output when that happens.