Prisma → Zod in one generate. Ship validated, typed data everywhere.
Prisma → Zod generator: zero‑boilerplate validation for your models.✍️ comment rules · ⚡ fast/minimal mode · 🎯 selective filtering · 🔒 strict types
- Zero‑boilerplate Zod schemas generated from your Prisma models
- Multiple variants for different layers: input, result, and pure models
- Fast minimal mode and filtering when you only need a subset
- Type‑safe across ESM/CJS, works great with TypeScript strict
- Node.js 18+
- Prisma installed and initialized (
npx prisma init
) - Zod installed (runtime for generated schemas)
-
Star this repo 🌟
-
Install
npm i -D prisma-zod-generator
# pnpm: pnpm add -D prisma-zod-generator
# yarn: yarn add -D prisma-zod-generator
# bun: bun add -d prisma-zod-generator
- Add a generator block to your
schema.prisma
generator zod {
provider = "prisma-zod-generator"
}
- Generate
npx prisma generate
- Import and use
// Default output exports an index; adjust path if you customized output
import { UserSchema } from './prisma/generated/schemas';
// Validate data
const parsed = UserSchema.safeParse({ id: 'clx...', email: '[email protected]' });
if (!parsed.success) console.error(parsed.error.format());
- Guides and recipes: https://omar-dulaimi.github.io/prisma-zod-generator/
- See
recipes/
in this repo for ready‑to‑copy setups
If this saves you time or prevents bugs, please consider sponsoring to support maintenance and new features.
→ https://github.com/sponsors/omar-dulaimi
PRs welcome. Keep diffs focused and discuss larger changes in an issue first. See the test suites for expected behavior and coverage.
MIT © Omar Dulaimi