prettier-plugin-curly

raw JSON →
0.4.1 verified Sat Apr 25 auth: no javascript

Prettier plugin to enforce consistent brace style for all control statements (for, if, while, etc.), adding curly braces around bodies. Current stable version is 0.4.1, released November 2025. It works alongside Prettier to enforce the equivalent of ESLint's curly 'all' rule, filling a gap where Prettier intentionally avoids modifying code structure. Requires Node >=18 and Prettier ^3. Version 0.4.0 introduced a complete rewrite using wrapped printers.estree. The plugin is actively maintained by JoshuaKGoldberg and the community.

error Error: Cannot find module 'prettier-plugin-curly'
cause Package not installed or Node.js cannot resolve it
fix
Run npm install prettier-plugin-curly --save-dev
error Error: The module 'prettier-plugin-curly' is not a Prettier plugin
cause Using incorrect import or path configuration
fix
In .prettierrc, use "plugins": ["prettier-plugin-curly"] (string name) not a path
error Error [ERR_REQUIRE_ESM]: require() of ES Module
cause Trying to use require() with ESM-only package (v0.4.0+)
fix
Use import syntax or downgrade to v0.3.x (but note Prettier 3 support may be limited)
error TypeError: prettierPluginCurly is not a function
cause Incorrectly destructuring default export
fix
Use import prettierPluginCurly from 'prettier-plugin-curly' (default import) not { prettierPluginCurly }
breaking Dropped support for Prettier 2 in v0.4.1
fix Upgrade to Prettier 3 and use prettier-plugin-curly ^0.4.1
breaking Complete rewrite in v0.4.0: plugin now exports a wrapped printers.estree instead of printers.ast
fix Ensure no custom printer overrides conflict with new internal architecture
deprecated CommonJS require() no longer works in v0.4.0+
fix Use ESM imports or upgrade to v0.4.1 which may have limited CJS support (check release notes)
gotcha Plugin modifies Prettier output for all control statements unconditionally; cannot be configured to skip certain statements
fix If selective behavior is needed, consider ESLint's curly rule instead
gotcha Plugin may conflict with other Prettier plugins that modify control statement printing
fix Ensure plugin order in 'plugins' array places prettier-plugin-curly before any conflicting plugins
npm install prettier-plugin-curly
yarn add prettier-plugin-curly
pnpm add prettier-plugin-curly

Configures Prettier to use prettier-plugin-curly; shows transformation of single-line if to curly brace style.

// .prettierrc
{
  "plugins": ["prettier-plugin-curly"]
}

// Before: if (x) doSomething();
// After prettier formatting:
// if (x) {
//   doSomething();
// }