Prisma to Zod Schema Generator
A tool that parses the model and enum definitions in schema.prisma and generates Zod validation schemas (z.object, z.enum) along with z.infer types. It can also output create schemas and use z.coerce.date() for DateTime, all within your browser.
How to use
- Paste your schema.prisma on the left, or load it with "Open file" or by drag and drop. You can also try it out with "Load sample".
- Zod schemas for every model and enum are generated automatically on the right.
- Under "Options", toggle create schemas, how DateTime is handled, and type exports.
- Save the result with "Copy to clipboard" or "Download schemas.ts" and add it to your project (requires the zod package).
About this tool
Zod is a popular schema declaration and validation library for TypeScript. When validating API requests or form input, hand-writing Zod schemas that mirror your Prisma database models is tedious and easy to forget to update when the models change. This tool generates Zod schemas from schema.prisma automatically.
Prisma types are mapped as String → z.string(), Int → z.number().int(), DateTime → z.date(), and enum → z.enum(). Length constraints like @db.VarChar(255) become .max(255), and nullable fields (String?) become .nullable(). The create schema option also outputs schemas where fields filled in by the database via @default or @updatedAt are optional.
Relation fields (references to other models) are left out to avoid circular references; only foreign key fields are included. schema.prisma is parsed with the same parser used by the Prisma Repository Code Generator and other Prisma tools. Nothing you enter is sent to a server.
Frequently asked questions
What do I need to use the generated code?
Install the zod package in your project (npm install zod). The generated code is written to work with both Zod 3 and Zod 4.
Can relation fields be included?
They're left out because models often reference each other, creating circular references that break type inference. If you need them, extend the generated schema with .extend().
How are Decimal and Json converted?
Decimal becomes z.number() for ease of use in APIs, and Json becomes z.unknown(), which accepts any value. Adjust them to suit your needs.
Is my schema sent to a server?
No. Parsing and code generation both happen in your browser.