Input Sanitization.Zero-Effort Zod Schemas.
The ultimate Prisma companion for runtime field protection and professional Zod schema generation. Protect your database from unknown fields with zero-config magic.
Protect, Generate, Validate
Prisma Guard bridges the gap between your database models and safe, validated application inputs — with zero manual boilerplate.
Runtime Field Protection
Mount as a Prisma Client extension to silently strip unknown fields from create, update, and nested operations before they reach the database.
Zod Schema Generation
Auto-generate complete, decorated Zod schemas from your Prisma models — including Create, Update, Scalar, and Required variants with full TypeScript types.
Comment Decorators
Fine-tune validation with triple-slash `///` comments directly in `.prisma` files. Supports multi-line refinements, `@zod.use`, and absolute overrides.
Named Validation Presets
Define reusable decorators with the `v` proxy in your config. Share across projects via npm packages — with full auto-import serialization.
Omission & Customization
Omit fields at global, model, or field level. Create named picks with `.as(Alias)` that bypass omissions. Override types with `@zod.z.` shorthand.
Zero-Config Magic
Automatic `.gitignore` management, Prettier formatting, generated folder cleanup, VS Code snippet installation, and watch mode — all out of the box.
Get Started in 2 Minutes
Four steps from zero to a fully protected Prisma Client with auto-generated Zod schemas.
Initialize
npx prisma-guard init
Creates a default prisma-guard.config.js in your project root.
Define Schema
model User {
id String @id @default(cuid())
email String @unique
password String
}Write your Prisma models as usual. Add /// decorators for custom validation.
Generate
npx prisma-guard
Auto-generates Zod schemas and runtime guard mappings from your models.
Protect
prisma.$extends(prismaGuard())
Mount the extension on your Prisma Client. Unknown fields are stripped automatically.
Two Ways to Use Prisma Guard
Choose the level of protection that fits your application — from a lightweight field stripper to a full validation suite.
Runtime Protection Only
Quick security, zero validation overhead
- Mount as a Prisma Client extension
- No Zod schemas generated
- Unknown fields silently stripped
- ~2µs per-query overhead
Full Validation
End-to-end schema safety
- Auto-generated Zod schemas
- Validate at API boundaries
- Clear structured error messages
- Create, Update, Scalar & Required variants
Ready to Secure Your Database?
One command to initialize, one command to generate. Your Prisma queries are protected in under two minutes.