format (Prisma CLI v7)
Format and validate your Prisma schema file with consistent structure
The prisma format command formats your Prisma schema file. It validates, formats, and persists the schema.
prisma format [options]Options
Section titled “Options”| Option | Description |
|---|---|
-h, --help |
Display help message |
--config |
Custom path to your Prisma config file |
--schema |
Custom path to your Prisma schema |
Examples
Section titled “Examples”Format the default schema
Section titled “Format the default schema”bunx prisma formatpnpm prisma formatyarn prisma formatnpx prisma formatOutput on success:
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Formatted prisma/schema.prisma in 116msFormat a specific schema
Section titled “Format a specific schema”bunx prisma format --schema=./alternative/schema.prismapnpm prisma format --schema=./alternative/schema.prismayarn prisma format --schema=./alternative/schema.prismanpx prisma format --schema=./alternative/schema.prismaError output
Section titled “Error output”If the schema has validation errors, formatting will fail:
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: Schema validation error - Error (query-engine-node-api library)
Error code: P1012
error: The preview feature "unknownFeatureFlag" is not known. Expected one of: [...]
schema.prisma:3
|
2 | provider = "prisma-client"
3 | previewFeatures = ["unknownFeatureFlag"]
|
Validation Error Count: 1