apps/docs/content/docs/cli/generate.mdx
The prisma generate command generates assets like Prisma Client based on the generator and data model blocks defined in your schema.prisma file.
prisma generate [options]
Add a generator definition in your schema.prisma file:
generator client {
provider = "prisma-client"
output = "./generated"
}
| Option | Description |
|---|---|
-h, --help | Display help message |
--config | Custom path to your Prisma config file |
--schema | Custom path to your Prisma schema |
--sql | Generate typed SQL module |
--watch | Watch the Prisma schema and regenerate after changes |
--generator | Generator to use (can be provided multiple times) |
--no-hints | Hide hint messages (still outputs errors and warnings) |
--require-models | Do not allow generating a client without models |
npx prisma generate
Output:
✔ Generated Prisma Client to ./node_modules/.prisma/client in 61ms
You can now start using Prisma Client in your code:
import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
npx prisma generate --schema=./alternative/schema.prisma
Automatically regenerate when the schema changes:
npx prisma generate --watch
Output:
Watching... /home/prismauser/prisma/schema.prisma
✔ Generated Prisma Client to ./node_modules/.prisma/client in 45ms
Run only specific generators:
npx prisma generate --generator client
Multiple generators:
npx prisma generate --generator client --generator zod_schemas
The prisma-client generator creates a customized client for working with your database. You can customize the output folder using the output field in the generator block.