Back to Prisma

format

apps/docs/content/docs/cli/format.mdx

latest1.3 KB
Original Source

The prisma format command formats your Prisma schema file. It validates, formats, and persists the schema.

Usage

bash
prisma format [options]

Options

OptionDescription
-h, --helpDisplay help message
--configCustom path to your Prisma config file
--schemaCustom path to your Prisma schema

Examples

Format the default schema

npm
npx prisma format

Output on success:

text
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Formatted prisma/schema.prisma in 116ms

Format a specific schema

npm
npx prisma format --schema=./alternative/schema.prisma

Error output

If the schema has validation errors, formatting will fail:

text
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