{"id":20405,"library":"prettier-plugin-prisma","title":"prettier-plugin-prisma","description":"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.","status":"active","version":"5.0.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/umidbekk/prettier-plugin-prisma","tags":["javascript","prettier-plugin","prisma"],"install":[{"cmd":"npm install prettier-plugin-prisma","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-prisma","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-prisma","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin requires Prettier >=2 or >=3 to function.","package":"prettier","optional":false},{"reason":"Core formatting logic; Wasm binary compiled from Prisma's official formatter.","package":"@prisma/prisma-schema-wasm","optional":false}],"imports":[{"note":"No explicit import needed; Prettier discovers the plugin automatically when installed. Also works with `prettier --plugin prettier-plugin-prisma`.","wrong":"// Adding to plugins array without installing the package","symbol":"default (plugin)","correct":"// In .prettierrc: { \"plugins\": [\"prettier-plugin-prisma\"] }"},{"note":"The plugin is CommonJS-compatible; require directly returns the plugin object.","wrong":"const prettierPluginPrisma = require('prettier-plugin-prisma').default;","symbol":"default (CommonJS require for programmatic use)","correct":"const prettierPluginPrisma = require('prettier-plugin-prisma');"},{"note":"ESM import works; the package has a 'default' export. TypeScript users may need `esModuleInterop`.","wrong":"import * as prettierPluginPrisma from 'prettier-plugin-prisma';","symbol":"default (ESM import for programmatic use)","correct":"import prettierPluginPrisma from 'prettier-plugin-prisma';"},{"note":"PluginOptions is a type-only export; use `import type` to avoid runtime errors.","wrong":"import { PluginOptions } from 'prettier-plugin-prisma';","symbol":"PluginOptions (TypeScript type)","correct":"import type { PluginOptions } from 'prettier-plugin-prisma';"}],"quickstart":{"code":"// 1. Install\nnpm i -D prettier prettier-plugin-prisma\n\n// 2. In .prettierrc (JSON or YAML)\n{\n  \"plugins\": [\"prettier-plugin-prisma\"],\n  \"tabWidth\": 2,\n  \"printWidth\": 100\n}\n\n// 3. Create a Prisma file: schema.prisma\ngenerator client {\n  provider = \"prisma-client-js\"\n}\n\ndatasource db {\n  provider = \"postgresql\"\n  url      = env(\"DATABASE_URL\")\n}\n\nmodel User {\n  id        Int      @id @default(autoincrement())\n  email     String   @unique\n  name      String?\n  posts     Post[]\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n}\n\nmodel Post {\n  id        Int      @id @default(autoincrement())\n  title     String\n  content   String?\n  author    User     @relation(fields: [authorId], references: [id])\n  authorId  Int\n  createdAt DateTime @default(now())\n}\n\n// 4. Run Prettier\nnpx prettier --write schema.prisma","lang":"typescript","description":"Demonstrates installing the plugin, configuring Prettier to use it, and formatting a .prisma schema file."},"warnings":[{"fix":"Review and commit any formatting changes after upgrading. No code changes required.","message":"v5.0.0 migrated from @prisma/prisma-fmt-wasm to @prisma/prisma-schema-wasm. The formatting output may differ slightly from previous versions.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Use Prisma CLI (`prisma validate`) for schema validation.","message":"Plugin only formats .prisma files; it does not lint or validate Prisma schema syntax.","severity":"gotcha","affected_versions":">=0"},{"fix":"Ensure Node.js version supports WASM (>=14). If issues persist, report to the plugin's GitHub issues.","message":"The plugin relies on a WASM binary; may not work in all restricted environments (e.g., some serverless platforms) without Node.js WASM support.","severity":"gotcha","affected_versions":">=0"},{"fix":"Upgrade to v5.0.0 or later to use the new WASM package.","message":"v4.x and earlier used @prisma/prisma-fmt-wasm. That dependency is deprecated in v5.","severity":"deprecated","affected_versions":"<5.0.0"},{"fix":"Run `npm i -D prettier-plugin-prisma` inside your project.","message":"Installing the plugin globally may not work; prefer local install in project devDependencies.","severity":"gotcha","affected_versions":">=0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install -D prettier-plugin-prisma` and ensure it's listed in package.json devDependencies.","cause":"Plugin not installed or Prettier cannot locate it.","error":"Cannot find module 'prettier-plugin-prisma'"},{"fix":"Add `\"plugins\": [\"prettier-plugin-prisma\"]` to your .prettierrc file.","cause":"Prettier is not configured to use the plugin.","error":"Error: No plugin detected for \"*.prisma\" files."},{"fix":"Use `const prettierPluginPrisma = require('prettier-plugin-prisma');` without `.default`.","cause":"Using CommonJS require incorrectly when plugin exports a single default object.","error":"TypeError: prettierPluginPrisma.default is not a function"},{"fix":"Ensure Node.js >=14 and no CSP blocking WASM. Use `--no-wasm` or upgrade Node.js.","cause":"WASM binary failed to load, possibly due to Content Security Policy or unsupported Node version.","error":"Prettier failed to load plugin due to WebAssembly.instantiateStreaming"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}