Registry / database / prettier-plugin-prisma

prettier-plugin-prisma

JSON →
library5.0.0jsnpmunverified

Prettier plugin for formatting Prisma schema files (.prisma). Current stable version is 5.0.0, released Dec 2023. It uses the official Prisma schema formatter WASM binary (@prisma/prisma-schema-wasm) to ensure formatting matches Prisma CLI output. The plugin auto-detects .prisma files and integrates seamlessly with Prettier. It requires Prettier >=2 or >=3 and Node >=14. Active development tracks Prisma releases closely, with frequent bumps to the underlying Prisma formatting engine.

npm install prettier-plugin-prisma
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-PR
P
prettier-plugin-prisma
databasejavascriptv5.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin)
✓ // In .prettierrc: { "plugins": ["prettier-plugin-prisma"] }
✗ // Adding to plugins array without installing the package
No explicit import needed; Prettier discovers the plugin automatically when installed. Also works with `prettier --plugin prettier-plugin-prisma`.
default (CommonJS require for programmatic use)
✓ const prettierPluginPrisma = require('prettier-plugin-prisma');
✗ const prettierPluginPrisma = require('prettier-plugin-prisma').default;
The plugin is CommonJS-compatible; require directly returns the plugin object.
default (ESM import for programmatic use)
✓ import prettierPluginPrisma from 'prettier-plugin-prisma';
✗ import * as prettierPluginPrisma from 'prettier-plugin-prisma';
ESM import works; the package has a 'default' export. TypeScript users may need `esModuleInterop`.
PluginOptions (TypeScript type)
✓ import type { PluginOptions } from 'prettier-plugin-prisma';
✗ import { PluginOptions } from 'prettier-plugin-prisma';
PluginOptions is a type-only export; use `import type` to avoid runtime errors.

Demonstrates installing the plugin, configuring Prettier to use it, and formatting a .prisma schema file.

// 1. Install npm i -D prettier prettier-plugin-prisma // 2. In .prettierrc (JSON or YAML) { "plugins": ["prettier-plugin-prisma"], "tabWidth": 2, "printWidth": 100 } // 3. Create a Prisma file: schema.prisma generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id Int @id @default(autoincrement()) email String @unique name String? posts Post[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Post { id Int @id @default(autoincrement()) title String content String? author User @relation(fields: [authorId], references: [id]) authorId Int createdAt DateTime @default(now()) } // 4. Run Prettier npx prettier --write schema.prisma
Debug
Known issues
breakingv5.0.0 migrated from @prisma/prisma-fmt-wasm to @prisma/prisma-schema-wasm. The formatting output may differ slightly from previous versions.
fix
Review and commit any formatting changes after upgrading. No code changes required.
affects: >=5.0.0
gotchaPlugin only formats .prisma files; it does not lint or validate Prisma schema syntax.
fix
Use Prisma CLI (`prisma validate`) for schema validation.
affects: >=0
gotchaThe plugin relies on a WASM binary; may not work in all restricted environments (e.g., some serverless platforms) without Node.js WASM support.
fix
Ensure Node.js version supports WASM (>=14). If issues persist, report to the plugin's GitHub issues.
affects: >=0
deprecatedv4.x and earlier used @prisma/prisma-fmt-wasm. That dependency is deprecated in v5.
fix
Upgrade to v5.0.0 or later to use the new WASM package.
affects: <5.0.0
gotchaInstalling the plugin globally may not work; prefer local install in project devDependencies.
fix
Run `npm i -D prettier-plugin-prisma` inside your project.
affects: >=0
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-prisma'
Plugin not installed or Prettier cannot locate it.
fix
Run `npm install -D prettier-plugin-prisma` and ensure it's listed in package.json devDependencies.
Error: No plugin detected for "*.prisma" files.
Prettier is not configured to use the plugin.
fix
Add `"plugins": ["prettier-plugin-prisma"]` to your .prettierrc file.
TypeError: prettierPluginPrisma.default is not a function
Using CommonJS require incorrectly when plugin exports a single default object.
fix
Use `const prettierPluginPrisma = require('prettier-plugin-prisma');` without `.default`.
Prettier failed to load plugin due to WebAssembly.instantiateStreaming
WASM binary failed to load, possibly due to Content Security Policy or unsupported Node version.
fix
Ensure Node.js >=14 and no CSP blocking WASM. Use `--no-wasm` or upgrade Node.js.
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies
prettierrequiredPeer dependency; plugin requires Prettier >=2 or >=3 to function.
@prisma/prisma-schema-wasmrequiredCore formatting logic; Wasm binary compiled from Prisma's official formatter.
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-prisma — npm install prettier-plugin-prisma · libregistry