Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

prisma-zod-generator

omar-dulaimi17.7kMIT1.9.2TypeScript support: included

Prisma 2+ generator to emit Zod schemas from your Prisma schema

prisma, prisma-client, prisma-schema, zod, prisma-generator, prisma-zod-generator

readme

Prisma Zod Generator

Prisma → Zod in one generate. Ship validated data everywhere.

npm version weekly downloads CI status MIT license TypeScript Module formats Docs

input · result · pure variants • comment rules • minimal mode • targeted filtering

📘 Docs: https://omar-dulaimi.github.io/prisma-zod-generator/

Prerequisites

  • Node.js 18+ (or Bun / Deno with Prisma compatibility layer)
  • Prisma (installed & npx prisma init done)
  • Zod (runtime dependency for the generated schemas)
  • TypeScript recommended (strict mode ideal)

Quick Start ⚡

1. Install (pick one)

# npm
npm i -D prisma-zod-generator zod
# pnpm
pnpm add -D prisma-zod-generator zod
# yarn
yarn add -D prisma-zod-generator zod
# bun
bun add -d prisma-zod-generator zod

2. Add to schema.prisma

generator zod {
    provider = "prisma-zod-generator"
}

3. Generate

npx prisma generate

4. Use

import { UserSchema } from './prisma/generated/zod';

Optional config: add prisma/zod-generator.config.json only if you need tweaks.

❤️ Sponsor

If this generator saves you engineering hours or reduces production risk, sponsoring keeps it fast, stable, and evolving.

Your support helps:

  • Prioritized issue triage & regression fixes
  • New variant / edge‑case coverage (providers, previews)
  • Performance & DX improvements (leaner outputs, smarter filtering)
  • Continued compatibility as Prisma & Zod evolve

Monthly tiers (GitHub Sponsors) unlock:

Tier Intended For Perks
Solo Indie devs 💖 Listed in README (opt‑in)
Team Startups Priority issues + roadmap influence
Scale Companies Early feature previews + escalation channel

➡️ Sponsor here: https://github.com/sponsors/omar-dulaimi

One‑off support also welcome (GitHub custom amount).

Contribute

PRs welcome. Keep diffs small; no unrelated refactors.

Before starting a feature or significant refactor: open an issue / feature request first (or discuss in an existing one) so we can:

  • Confirm scope & fit
  • Avoid duplicate / misaligned work
  • Point you to internal patterns or existing WIP

Okay to skip issue for: typo fixes, tiny docs tweaks, test flake isolation.

See tests for coverage expectations.

License

Released under the MIT License – see LICENSE for full text.

Built & maintained by Omar Dulaimi with community contributors.

changelog

1.9.2 (2025-08-13)

🐛 Bug Fixes

  • prisma-import: point Zod schema Prisma imports to client entry for new prisma-client generator (f009211)

1.9.1 (2025-08-13)

🐛 Bug Fixes

  • docs: resolve Docusaurus SSG error by fixing MDX style/class props and update internal links (#contributing, homepage) (0f04448)

📚 Documentation

  • readme: restore prominent docs website badge/link (9105ef3)
  • readme: streamline quick start, sponsor & contribute guidance, add badges (596a8f3)

1.9.0 (2025-08-13)

🚀 Features

  • docs,homepage: mobile hero refinements, button redesign, badge replacement, GitHub CTA styling (529bbc8)

♻️ Code Refactoring

  • types: remove explicit any in source/tests and ignore docusaurus build artifacts (163d6be)

📚 Documentation

  • add Docusaurus site, version 1.8.0 snapshot, automation & link checks (8590d02)

1.8.0 (2025-08-13)

⚠ BREAKING CHANGES

  • pure-models: pure model exports are now *Schema and only <Model>.schema.ts files are generated (no <Model>.model.ts). Updated README. Adjust your imports accordingly.
  • pureModels: pureModels no longer emits relation (object) fields unless pureModelsIncludeRelations=true. Set that flag to retain prior behavior. Added config parsing, defaults, docs, and tests.

🚀 Features

  • config: add pureModelsLean and dateTimeStrategy options with docs and schema updates (dc3784c)
  • custom-use: add @zod.custom.use override, helper exports, and tests (72f7b4d)
  • models: overhaul pure model generation (Model naming, lean mode, enum schema refs, DateTime strategies, single-file optimization) (8462d32)
  • naming: add stable naming customization presets and docs (8d611d8)
  • pure-models: unify pure model naming to *Schema and single .schema.ts output (5234631)
  • pureModels: omit relation fields by default; add pureModelsIncludeRelations flag (cf9eef4)
  • pure: support pure-only variant mode (skip CRUD/object schemas when only pure enabled) (9d4527b)
  • variants,imports: unify enum schema usage across variant generators and dynamic Prisma client import paths (a2e126a)
  • variants): refined enum handling for pure variant & chore(test: migrate from deprecated basic reporter (375fcb8)

🐛 Bug Fixes

  • config: honor JSON config output when generator block omits output\n\nDefers output path initialization so JSON 'output' is used if schema block lacks output (block > JSON > default). (5bc90b9)
  • generator: honor config output path and correct enum import paths in pure model schemas (5393d98)
  • json: align helper file after template update (77ecfe5)
  • json: drop Prisma.JsonValue references for v6 compatibility and use structural JSON types (8fef5f7)
  • prisma-client-preview: correct import path handling for preview prisma-client generator and file extensions (65925e2)

♻️ Code Refactoring

  • json: centralize JSON helper schema generation and adjust single-file bundling (2102256)

📚 Documentation

  • recipes: add CRUD-only, input-only, result-only recipe examples (36d6702)
  • recipes: add pure-models-lean recipe with DateTime strategy examples (dcd773a)

[Unreleased]

🚀 Features

  • naming: introduce stable naming customization (presets: zod-prisma, zod-prisma-types, legacy-model-suffix) with tokenized file/export patterns and legacy alias support.

📚 Documentation

  • readme: add comprehensive naming customization guide (presets, migration tips, precedence) and mark feature stable.

1.7.0 (2025-08-12)

🚀 Features

  • bytes: align Prisma Bytes mapping with v6 (Uint8Array) and update tests\n\n- I/O schemas: map Bytes to z.instanceof(Uint8Array)\n- Pure models: default to base64 string with size checks; opt-out to Uint8Array via config\n- Update tests and docs/comments accordingly\n\nBREAKING CHANGE: Prisma Bytes now validated as Uint8Array in generated I/O schemas. Pure model default remains base64 string, with config to use Uint8Array. (15ca502)

📚 Documentation

  • recipes: fix wrong file names and snippet paths in recipe READMEs; clarify usage steps (20ec581)
  • recipes: remove top-level snippets and update references to recipes/*\n\n- Delete snippets/ folder\n- Update README and recipes/README to point to recipes/<name>/schema.prisma\n- Keep historical mention in CHANGELOG as-is (3aa4009)

1.6.0 (2025-08-11)

🚀 Features

  • docs: add recipes and snippets with generator block examples and configs (bb284c7)

🐛 Bug Fixes

  • prisma: add User.password to align generated create inputs with tests (8485187)

♻️ Code Refactoring

  • config: improve option parsing and precedence; add tagged warnings and info messages (81b0d91)

📚 Documentation

  • readme: clarify config precedence and logging with tagged messages (96d705b)

1.5.0 (2025-08-10)

🚀 Features

  • config,transformer: add strictCreateInputs/preserveRequiredScalarsOnCreate and apply to Create-like inputs; use Omit<> for typed exports when filtered\n\n- config: introduce strictCreateInputs (default true) and preserveRequiredScalarsOnCreate (default true)\n- transformer: respect flags for Create* inputs; re-add required scalars in filtered mode; track excluded fields and wrap typed exports with Omit<>\n- tests/recipes/docs: update helpers and recipes; document options in README (cf48027)

🐛 Bug Fixes

  • ensure enum value imports are present in variant schemas (post-merge release trigger) (aed7e61)

1.4.2 (2025-08-10)

🐛 Bug Fixes

  • ensure enum value imports are present in variant schemas (post-merge release trigger) (b3dde64)

1.4.1 (2025-08-09)

🐛 Bug Fixes

  • transformer: correct list handling to avoid duplicate array() and support DateTime[] union\n\n- Use z.union([z.date().array(), z.iso.datetime().array()]) for DateTime lists\n- Append .array() only once and collapse accidental duplicates\n- Preserve optionality behavior with enhanced schemas (2e75b93)

1.4.0 (2025-08-09)

🚀 Features

  • logging: hide verbose logs by default and gate them behind DEBUG_PRISMA_ZOD/DEBUG\n\n- Add central logger (src/utils/logger.ts)\n- Convert noisy console.log to logger.debug/info/warn\n- Keep warnings/errors visible without DEBUG (703f716)

1.3.1 (2025-08-09)

🐛 Bug Fixes

  • objects: inline object schema exports and add dual exports (typed + pure Zod) (4af455c)
  • whereUniqueInput: require and restrict fields to unique identifiers only for WhereUniqueInput (becd08b)

1.3.0 (2025-08-09)

🚀 Features

  • Add comprehensive debug logging for filtering (5309680)
  • add core configuration and type system (2923825)
  • Add example configuration and update test schema (aca8311)
  • Add legacy configuration transformation and auto-discovery (f5612a5)
  • add schema variant system (f133d1a)
  • add utility modules (3446571)
  • Enhance configuration auto-discovery in generator (2985a4b)
  • generator: add strict single-file output mode with in-process aggregator; skip variants in single-file; place bundle at output root by default via placeSingleFileAtRoot; include tests and validation tsconfig (2296b30)
  • implement foreign key preservation for excluded relation fields (52897f3)
  • integrate advanced filtering and configuration (20a5313)
  • integrate zod-integration system with main generator pipeline (fcc396e)
  • validation: add comprehensive schema validation infrastructure (6da9e61)
  • variants: generate array/object variants under schemas/variants by default and add variants barrel to main index; fix index exports\n\nAlso: pure models improvements (Bytes base64 mapping, JSON record handling, dedupe defaults), union formatting to single line, enum string arrays, and minimal-mode schema emission stability. All feature tests pass. (9ea8a46)

🐛 Bug Fixes

  • ci: generate per-file schemas in example to satisfy tests (useMultipleFiles=true) (c32e6b8)
  • config: resolve tsconfig.json typeRoots and include paths (976fb49)
  • correct config path handling in field exclusion tests (67bcbf2)
  • correct test configurations and schema generation issues (d1af961)
  • enhance @zod annotation parsing and validation (f965e22)
  • enhance @zod method parameter validation for custom error messages (4d06ec4)
  • Enhance model filtering to prevent disabled model schemas in nested folders (c34e995)
  • generator: correct Zod method chaining order for optional and nullable fields (0effdf2)
  • implement comprehensive Zod comment parsing engine (154aaa1)
  • Improve field exclusion system and foreign key preservation (e857e6a)
  • improve regex validation and resolve optional redundancy in zod schema generation (5ccce49)
  • prevent duplicate .optional() calls in enhanced zod schemas (b7eb5e0)
  • remove unused ObjectSchema imports from result schemas (488e838)
  • replace deprecated Zod API usage (9e46bcc)
  • replace deprecated Zod API usage (92d2537)
  • resolve @zod annotation method validation and parameter formatting (918d15c)
  • Resolve config path resolution issues in tests (2cdb6fc)
  • resolve ESLint errors to unblock release (unused vars, require->import) (becfbdb)
  • resolve field exclusion system configuration issues (2f50c4a)
  • resolve test configuration and template variable issues (fc10758)
  • update supporting modules and test infrastructure (0bd5d56)

♻️ Code Refactoring

  • enhance helper modules with filtering support (4938d6e)
  • parser: remove duplicate base type method configurations (4f5f7f1)

📚 Documentation

  • add comprehensive documentation (d96c872)

1.2.0 (2025-08-07)

🚀 Features

  • implement community generator aggressive inlining pattern (d5675c0)
  • implement dual schema export strategy to solve TypeScript method trade-off (9cba538)
  • implement selective inlining for select schemas (0a1c921)
  • implement true select schema inlining following community generator pattern (be01d20)
  • removes the forced ZodType to allow the use of ZodObject properties and methods (df36da4)

🐛 Bug Fixes

  • dual export configuration parsing bug (e4b6853)
  • improve TypeScript type inference with explicit Prisma bindings (cb14493)
  • model hiding functionality for @@Gen.model(hide: true) (fe4567e)
  • resolve field name detection bug in generateObjectSchemaField (94508ae)
  • resolve FindMany union validation issue and improve composition approach (92d9301)
  • use Buffer instead of Uint8Array for bytes field in test (4608156)

📚 Documentation

  • add composition approach design documentation (dc4ecc5)
  • add comprehensive dual export configuration guide (6628842)
  • update comparison with aggressive inlining achievement (b47449f)

1.1.1 (2025-07-30)

🐛 Bug Fixes

  • improve ESM import handling and type validation (c07d384)
  • resolve ESLint errors in ESM configuration tests (9687c1d)

📚 Documentation

  • add preview features support section to README (a348446)
  • remove beta sections and references from README (32edf33)

1.1.0 (2025-07-25)

🚀 Features

  • add support for new prisma-client generator (46cdc02), closes #127

1.0.7 (2025-07-25)

🐛 Bug Fixes

  • add explicit type annotations to prevent TypeScript implicit any errors (ef50308)

1.0.6 (2025-07-25)

🐛 Bug Fixes

  • correct skipDuplicates support for database providers (0511785)

1.0.5 (2025-07-25)

🐛 Bug Fixes

  • remove package/package.json from git add in release workflow (254ad28)
  • resolve TypeScript compilation errors in generated schemas (85d10a8)

1.0.5 (2025-07-23)

🐛 Bug Fixes

  • remove package/package.json from git add in release workflow (254ad28)

1.0.4 (2025-07-23)

🐛 Bug Fixes

  • remove unused error parameters in test catch blocks (025b822)
  • resolve output directory duplication when path ends with 'schemas' (e200115), closes #118

1.0.3 (2025-07-22)

🐛 Bug Fixes

  • resolve TypeScript inference issues with z.lazy() relations (6da8eb8)

📚 Documentation

  • remove hardcoded version numbers from README (95d6cbd)

1.0.2 (2025-07-22)

🐛 Bug Fixes

  • resolve schema compilation errors in Issue #119 (3f29b48)
  • resolve Vitest worker timeout in CI (08a5546)

1.0.1 (2025-07-22)

🐛 Bug Fixes

  • remove broken logo image from README (eb2ba51)

📚 Documentation

  • update README for v1.0.0 stable release (0f267c9)

1.0.0 (2025-07-22)

🚀 Features

  • add comprehensive CI/CD automation and release workflows (cb562f5)
  • add support for new prisma-client generator (8224aed), closes #116
  • configure semantic-release for beta releases from upgrade branch (6dfdd98)
  • enable semantic-release for upgrade branch (d6ef9b3)
  • remove strict requiresGenerators constraint (6e1d41b), closes #116

🐛 Bug Fixes

  • add MongoDB schema generation step to CI workflow (b120f12)
  • add skipDuplicates option to createMany query (710d522)
  • adjust MongoDB test expectations for CI compatibility (0c53f60)
  • adjust provider discovery test and fix more ESLint issues (bb83e97)
  • adjust test expectations and resolve remaining ESLint issues (d1ae46e)
  • convert vitest config to JavaScript for better Node 18 compatibility (0106c4f)
  • correct branch references from main to master in CI/CD workflows (009aa79)
  • no array around createManyInput (a244cac)
  • prevent NaN errors in MongoDB test success rate calculations (1498a80)
  • replace absolute paths with relative paths in provider schemas (97cb362)
  • resolve all remaining ESLint any type warnings (b26ea59)
  • resolve CI test failures and ESLint issues (89ba9e6)
  • resolve ESLint configuration and CI issues (df52348)
  • resolve MongoDB schema coverage test import issues (989addd)
  • skip vitest tests for Node 18 due to Vite 7.x requirements (93605e1)
  • update dependabot configuration (d5f57fb)
  • update package-lock.json with semantic-release dependencies (814be64)
  • update vitest config for v3 compatibility with Node 18 (7f34eab)
  • use correct DMMF namespace import alias (a495445)

📚 Documentation

  • add beta testing announcement to README (1b0bfb2)
  • add comprehensive CI/CD workflow usage guide (3da4f92)
  • add prominent support section to README (0803dc3)
  • clarify GitHub secrets setup for repository vs environment secrets (c8ea5cc)
  • clarify test schema purpose for new generator (659c4e0)
  • comprehensive README improvements (9d014b9)
  • correct link in table of contents (918f862)
  • focus beta announcement on Prisma 6 & Zod 4 compatibility (087c257)
  • improve NPM token setup instructions and troubleshooting (8f379f9)
  • modernize README with enhanced styling and comprehensive content (1f226a1)
  • update README for Prisma 6 and Zod 4 support (bdac9dd)
  • update to v0.8.15-beta.0 with new generator support (7372825)

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[Unreleased]

Added

  • Comprehensive CI/CD pipeline with GitHub Actions
  • Automated release workflow with semantic versioning
  • Multi-provider database testing infrastructure
  • Extended test matrix for cross-platform compatibility
  • Dependabot configuration for automated dependency updates
  • Semantic release configuration for automated changelog generation

Changed

  • Improved test command reliability and compatibility
  • Updated ESLint configuration for better TypeScript support
  • Enhanced vitest configuration for better performance

Fixed

  • Test command compatibility issues with Zod v4
  • Undefined config errors in multi-provider tests
  • TypeScript type checking configuration

This changelog is automatically generated using semantic-release.