npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

prazod

v1.1.0

Published

A CLI that keeps your Zod schemas in sync with your Prisma models. It generates modular, type-safe validation files automatically, ensuring your database and application logic stay aligned.

Readme

Prazod

A CLI that keeps your Zod schemas in sync with your Prisma models. It generates modular, type-safe validation files automatically, ensuring your database and application logic stay aligned.

Current Status

⚠️ This is a proof of concept (POC) - The library is currently in active development and should be used for experimental purposes. While functional, it may not be production-ready for all use cases.

Donate

Support the Project

To keep this library maintained and evolving, your contribution would be greatly appreciated! It helps keep me motivated to continue collaborating and improving this framework for everyone.

Donate via PayPal

Prerequisites

  • [x] Node.js >= 22.0.0
  • [x] Yarn >= 1.x

📚 Documentation

:package: Installation

# Global install (once)
npm install -g prazod   # or pnpm add -g prazod
# Run without installing (npx)
npx prazod schema.prisma output.ts --modular

Reverse Generation (Zod -> Prisma)

Prazod also supports generating a Prisma schema from existing Zod schemas. This is useful when you want to prototype with Zod first or migrate an existing Zod-based project to Prisma.

# Generate Prisma schema from Zod file
prazod reverse ./src/zod-schemas.ts ./prisma/schema.prisma

Supported Features

  • Models: Zod objects are converted to Prisma models.
  • Enums: Zod enums are converted to Prisma enums.
  • Attributes:
    • @id: Inferred from id field or .cuid()/.uuid() validations.
    • @default: Inferred from .default() values.
    • @updatedAt: Inferred from updatedAt field name.
    • @unique: Inferred from .describe("@unique").
    • @relation: Parsed from .describe() (e.g., .describe("@relation(fields: [userId], references: [id])")).
    • @map: Parsed from .describe() (e.g., .describe('@map("column_name")')).
    • Native Types: Parsed from .describe() (e.g., .describe("@db.Text")).
  • Model Attributes:
    • @@index: Parsed from model documentation.
    • @@id: Parsed from model documentation (for composite IDs).
    • @@unique: Parsed from model documentation (for composite unique constraints).
    • @@fulltext: Parsed from model documentation (for full-text search indexes).
    • @@map: Parsed from model documentation.
  • Types:
    • z.string() -> String
    • z.number() -> Float (or Int if .int() is used)
    • z.boolean() -> Boolean
    • z.date() -> DateTime
    • z.enum() -> Enum
    • z.lazy(() => Model) -> Model (for relations)

Limitations

  • Database Provider: Defaults to postgresql. You may need to adjust the datasource block manually.
# Local dev dependency (recommended for projects)
pm install --save-dev prazod   # or pnpm add -D prazod

Add the script to your package.json:

{
  "scripts": {
    "generate:zod": "prazod prisma/schema.prisma src/zod-schemas --modular"
  }
}

:rocket: Usage

Single File Mode (Default)

prazod examples/ecommerce.prisma output.ts

Modular Mode

Generate organized folder structure with separate files:

prazod examples/ecommerce.prisma output-dir --modular

Examples

Check out the examples/ directory for sample Prisma schemas:

For local development:

pnpm build && node dist/index.js examples/ecommerce.prisma examples/ecommerce-zod --modular

:sparkles: Supported Prisma Features

Scalar Types

All Prisma scalar types are fully supported:

  • String, Int, BigInt, Float, Decimal
  • Boolean, DateTime, Json, Bytes

Default Value Functions

  • autoincrement() - Auto-incrementing integers
  • now() - Current timestamp
  • uuid() - UUID v4 generation
  • cuid() - Collision-resistant ID
  • auto() - MongoDB ObjectId (auto-generated)
  • sequence() - CockroachDB sequences with options
  • ulid() - Lexicographically sortable IDs
  • nanoid() - Nano IDs with custom length
  • dbgenerated() - Database-level default expressions

Field Attributes

  • @id - Primary key
  • @unique - Unique constraint
  • @default - Default value
  • @updatedAt - Automatic update timestamp
  • @relation - Define relationships
  • @map - Column name mapping
  • @ignore - Exclude from Zod schema (field will be omitted)

Model Attributes

  • @@id - Composite primary key
  • @@unique - Composite unique constraint
  • @@index - Database index
  • @@map - Table name mapping
  • @@ignore - Exclude model from Zod schemas (file will not be generated)

Relations

  • One-to-one, one-to-many, and many-to-many relationships
  • Self-relations and bi-directional relations
  • Relation actions: Cascade, Restrict, NoAction, SetNull

Enums

Full enum support with proper Zod enum generation

:handshake: Contributing

We welcome contributions! Please read our Contributing Guide and Code of Conduct before submitting pull requests.

Quick start:

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

:busts_in_silhouette: Credits


:anger: Troubleshootings

This is just a personal project created for study / demonstration purpose and to simplify my working life, it may or may not be a good fit for your project(s).


:heart: Show your support

Please :star: this repository if you like it or this project helped you!
Feel free to open issues or submit pull-requests to help me improving my work.


:robot: Author

Chris M. Perez

You can follow me on github · twitter


Copyright ©2025 prazod.