{"id":48968,"library":"prisma-zod-generator","title":"Prisma Zod Generator","description":"Prisma Zod Generator (v2.1.4) is a Prisma generator that emits Zod schemas from your Prisma schema, enabling end-to-end validation with Zod. It supports both ESM and CJS, requires Node >=20.19.0 and Zod >=3.25.0 <5. Key differentiators include multiple generation modes (minimal, full, custom), schema variants, decimal handling, DateTime support, naming patterns, selective generation, and a paid Pro tier with additional features like policy guardrails and Drift Guard. Active development with frequent releases.","status":"active","version":"2.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/omar-dulaimi/prisma-zod-generator","tags":["javascript","prisma","prisma-client","prisma-schema","zod","prisma-generator","prisma-zod-generator"],"install":[{"cmd":"npm install prisma-zod-generator","lang":"bash","label":"npm"},{"cmd":"yarn add prisma-zod-generator","lang":"bash","label":"yarn"},{"cmd":"pnpm add prisma-zod-generator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: Zod is required for schema generation and validation","package":"zod","optional":false}],"imports":[{"note":"Generated files are typically in a 'zod' subdirectory under the output path. Use named imports for specific model schemas.","wrong":"const { UserSchema } = require('./generated/zod')","symbol":"Generated schemas","correct":"import { UserSchema, UserCreateInputSchema } from './generated/zod'"},{"note":"The generated index file has a default export containing all schemas as an object. Available since v2.","wrong":"const schemas = require('./generated/zod')","symbol":"Default export from generated file","correct":"import schemas from './generated/zod'"},{"note":"Prisma Zod Generator only generates Zod schemas; Prisma Client is still needed for database operations.","wrong":"","symbol":"Prisma client usage","correct":"import { PrismaClient } from '@prisma/client'"}],"quickstart":{"code":"// 1. Install dependencies\nnpm install prisma-zod-generator zod\n\n// 2. Add to Prisma schema (schema.prisma)\ngenerator zod {\n  provider = \"prisma-zod-generator\"\n  output   = \"./generated/zod\"\n}\n\n// 3. Run Prisma generate\n// npx prisma generate\n\n// 4. Use generated schemas in your code\nimport { UserCreateInputSchema } from './generated/zod';\n\nconst result = UserCreateInputSchema.safeParse({\n  email: 'user@example.com',\n  name: 'John Doe'\n});\n\nif (!result.success) {\n  console.error(result.error);\n}\n\n// Full mode also exports ObjectSchemas (e.g., UserSchema) for validation of full objects","lang":"typescript","description":"Install and configure Prisma Zod Generator, then validate Prisma model input using the generated Zod schema."},"warnings":[{"fix":"Use an absolute path or a path relative to the project root, e.g., output = \"./src/generated/zod\"","message":"Generator output path is relative to the project root, not the schema file location. Misconfiguration leads to 'Cannot find module' errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate to v2 by removing 'Zod' prefix from import names. For example, 'ZodUser' becomes 'UserSchema'.","message":"In v1, the generator produced schemas with 'Zod' prefix (e.g., ZodUser). v2 dropped the 'Zod' prefix to simplify imports.","severity":"deprecated","affected_versions":"<2.0.0"},{"fix":"Update Node.js to v20.19.0 or later.","message":"Node.js version requirement was bumped from >=14 to >=20.19.0 in v2, breaking compatibility with older Node releases.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Rename mode from 'custom' to 'default' in Prisma schema generator config.","message":"The 'custom' mode configuration option has been renamed to 'default' in v2.1. Using 'custom' will still work but logs a deprecation warning.","severity":"deprecated","affected_versions":">=2.1.0"},{"fix":"Ensure that 'compilerOptions.paths' or 'include' in tsconfig.json covers the output directory of the generated schemas.","message":"When using TypeScript, the generated Zod schemas may require specific tsconfig paths or include patterns to be resolved correctly.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'20.19.0':36 '3.25.0':39 '5':40 'activ':74 'addit':66 'cjs':33 'client':83 'custom':49 'datetim':54 'decim':52 'develop':75 'differenti':42 'drift':72 'emit':13 'enabl':20 'end':22,24 'end-to-end':21 'esm':31 'featur':67 'frequent':77 'full':48 'generat':3,6,11,45,59,90,94 'guard':73 'guardrail':70 'handl':53 'includ':43 'javascript':79 'key':41 'like':68 'minim':47 'mode':46 'multipl':44 'name':56 'node':35 'paid':62 'pattern':57 'polici':69 'prisma':1,4,10,18,80,82,85,89,92 'prisma-cli':81 'prisma-gener':88 'prisma-schema':84 'prisma-zod-gener':91 'pro':63 'releas':78 'requir':34 'schema':15,19,50,86 'select':58 'support':29,55 'tier':64 'v2.1.4':7 'valid':25 'variant':51 'zod':2,5,14,27,38,87,93","created_at":"2026-06-07T16:59:23.050794+00:00","updated_at":"2026-06-07T16:59:23.050794+00:00","problems":[{"fix":"Check that the 'output' path in schema.prisma is correct and run 'npx prisma generate'.","cause":"Generator output path is misconfigured or Prisma generate hasn't been run.","error":"Error: Cannot find module './generated/zod'"},{"fix":"Ensure you are importing the correct named export (e.g., UserCreateInputSchema) and that the generator ran successfully.","cause":"Importing a wrong export or the generated schema is not a Zod object.","error":"TypeError: UserCreateInputSchema.safeParse is not a function"},{"fix":"Update to v1.5.0+ which includes Decimal handling, or configure a custom Zod type mapping.","cause":"Prisma Decimal type is not handled by default; need to configure custom Zod types.","error":"Error: Unknown type: Decimal","affected_versions":"<1.5.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://omar-dulaimi.github.io/prisma-zod-generator","github":"https://github.com/omar-dulaimi/prisma-zod-generator","docs":null,"changelog":null,"pypi":null,"npm":"prisma-zod-generator","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}