Binary Location
After building:Command Line Interface
The prisma-fmt binary supports multiple modes:format
Format a Prisma schema file:Input file to format. If not specified, reads from stdin.
Output file for formatted content. If not specified, writes to stdout.
Number of spaces for indentation
native-types
Get available native types for database connectors:referential-actions
Get available referential actions for the datasource:preview-features
List all available preview features:debug-panic
Artificially panic for testing error handling:Language Server Protocol (LSP)
Prisma-fmt implements the Language Server Protocol for editor integration. It’s typically used through editor extensions, not invoked directly.LSP Features
Formatting
Completion
- Model and field names
- Attribute names (
@id,@unique, etc.) - Datasource providers
- Generator configurations
- Relation field types
Hover Information
- Field types
- Attributes
- Native types
- Relations
Code Actions
- Add missing
@relationattributes - Create missing opposite relation fields
- Add missing
@mapor@@mapattributes - Fix relation names
Find References
- Models
- Fields
- Enums
Rename
Document Symbols
- Models
- Enums
- Datasources
- Generators
Editor Integration
Prisma-fmt is typically used through editor extensions:VS Code
The Prisma VS Code extension uses prisma-fmt:Neovim
Using nvim-lspconfig:Other Editors
Any LSP-compatible editor can use prisma-fmt by configuring it as a language server for.prisma files.
Building the Binary
1
Build with Cargo
2
Find the binary
3
Test formatting
WebAssembly Build
Prisma-fmt is also available as a WebAssembly module for use in browsers:./target/prisma-schema-wasm/
WASM API
Testing
Prisma-fmt uses snapshot testing withexpect-test:
Example Test
Environment Variables
Configure logging verbosity (e.g.,
debug, prisma_fmt=trace)Update expect-test snapshots during test runs
Related Documentation
Prisma Format Component
Deep dive into prisma-fmt architecture
PSL Overview
Prisma Schema Language specification
PSL Parser
How schema parsing works
PSL Validation
Schema validation system