prisma format
Format your Prisma schema file(s) for consistent style and readability.Usage
Options
Display help message.Alias:
-hCustom path to your Prisma config file.
Custom path to your Prisma schema.
Check if the schema is formatted without modifying it. Exits with error if formatting is needed.
Examples
Basic formatting
Check if formatted
1 when files need formatting.
Format custom schema
What Gets Formatted
The formatter applies consistent styling to:1. Indentation
Before:2. Field Alignment
Before:3. Block Spacing
Before:4. Comment Preservation
Before:5. Attribute Ordering
Before:@id before @default).
Multi-File Schema Formatting
When using multi-file schemas, all files are formatted:Integration with Development Workflow
Pre-commit Hook
Format schema files before committing:CI/CD Pipeline
Check formatting in CI:--check flag causes the command to fail if files aren’t formatted.
VS Code Integration
The Prisma VS Code extension can format on save:Format on Generate
The schema is automatically formatted when you run:Error Handling
If the schema has syntax errors, formatting will fail:Formatting Rules
The Prisma formatter follows these rules:- 2-space indentation for nested blocks
- Align field types in models and enums
- Align attributes on the same line
- Single blank line between top-level blocks
- No trailing whitespace
- Consistent spacing around operators and keywords
- Preserve comments with proper alignment
- Sort attributes by priority (e.g.,
@idbefore@default)
Exit Codes
0- Formatting successful (or already formatted with--check)1- Formatting failed or files need formatting (with--check)
Related Commands
prisma validate- Validate schema before formattingprisma generate- Generate Prisma Client (auto-formats)prisma db pull- Pull schema from database (auto-formats)