Clean up a schema
Run it after editing a schema to normalize its structure and catch validation problems.
Prisma · Command
prisma format validates and reformats a Prisma schema, saving the result. Use --schema or --config when the schema or Prisma configuration is stored at a custom path.
Run this Prisma CLI command to validate and reformat a schema file, then persist the formatted result. By default, Prisma uses the project’s default schema; use --schema to select another file, and --config to select a custom Prisma configuration.
prisma format [options]| Name | Type | Description |
|---|---|---|
-h, --help | flag | Displays command help. |
--config | option | Specifies a custom Prisma configuration file path. |
--schema | option | Specifies a custom Prisma schema path. |
Formats and persists the schema; formatting fails when schema validation errors are present.
npx prisma format --schema=./prisma/schema.prismaFormats and validates the specified Prisma schema file in place.
Run it after editing a schema to normalize its structure and catch validation problems.
Format a schema outside the project default location.
Use a non-default Prisma configuration file.
It validates the schema, formats it consistently, and saves the formatted schema. Running it without a path targets the default schema.
Follow-up: How would you target a non-default schema? Use --schema followed by its relative or absolute path.
The command syntax is prisma format [options]. The documented options include --schema for a custom schema path and --config for a custom Prisma config path.
Follow-up: What option displays command help? Use -h or --help.
A validation failure prevents formatting from succeeding. The schema must therefore be valid before Prisma can persist the formatted result.
Follow-up: How could a project format schemas automatically while editing? Prisma documentation also describes formatting through the Prisma VS Code extension.
Prisma schemaPrisma VS Code extensionprisma validate