Registry / web-framework / prettier-plugin-blade

prettier-plugin-blade

JSON →
library3.1.5jsnpmunverified

An opinionated Prettier plugin for formatting Laravel Blade templates, currently at version 3.1.5 (stable). It requires Node.js >=18 and Prettier ^3.0, and optionally integrates with @prettier/plugin-php for embedded PHP formatting and prettier-plugin-tailwindcss for Tailwind CSS class sorting. Key differentiators include a ground-up rewrite in v3 with changed output, Blade syntax plugins for frameworks like Statamic, and extensive configuration options for directive spacing, echo spacing, component prefixes, and inline element behavior. Released frequently with bug fixes and improvements. Active development.

npm install prettier-plugin-blade
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-BL
P
prettier-plugin-blade
web-frameworkjavascriptv3.1.5
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.

plugin (in .prettierrc plugins array)
✓ module.exports = { plugins: ['prettier-plugin-blade'] }
✗ require('prettier-plugin-blade')
This is a Prettier plugin, not imported directly in JS. Configure in .prettierrc or CLI.
parser (blade)
✓ { parser: 'blade' }
✗ { parser: 'blade.php' }
The parser string is just 'blade', not the file extension.
options (in .prettierrc)
✓ module.exports = { plugins: ['prettier-plugin-blade'], overrides: [{ files: ['*.blade.php'], options: { parser: 'blade' } }] }
✗ { parser: 'blade' } inside overrides without files array
Override must specify files matching Blade templates, e.g. ['*.blade.php'].

Basic .prettierrc configuration to format Blade templates with Prettier.

module.exports = { plugins: ['prettier-plugin-blade'], overrides: [{ files: ['*.blade.php'], options: { parser: 'blade', tabWidth: 4 } }] };
Debug
Known issues
breakingChisel v3 is a ground-up rewrite: output changes compared to v2.
fix
Pin to previous version (e.g., prettier-plugin-blade@^2) if you need stable output, or update your codebase to accommodate v3 formatting.
affects: >=3.0.0
deprecatedPrettier v2 is not supported; requires Prettier ^3.0.0.
fix
Upgrade Prettier to v3: npm install prettier@^3 --save-dev
affects: >=3.0.0
gotchaThe plugin requires Node.js >=18.0.0; older versions will fail.
fix
Ensure Node.js version is 18 or higher: node --version
affects: >=3.0.0
gotchaWhen using PHP formatting (bladePhpFormatting: 'safe'), @prettier/plugin-php must be installed and in plugins list.
fix
Install @prettier/plugin-php and add to plugins array in .prettierrc.
affects: >=3.0.0
gotchaCLI array options must be repeated per item (e.g., --blade-component-prefixes x --blade-component-prefixes flux), not comma-separated.
fix
Use repeated flags for array values in CLI. Use JSON array in .prettierrc for ease.
affects: >=3.0.0
gotchabladeDirectiveCaseMap option is a JSON object; passing it via CLI requires careful quoting.
fix
Set bladeDirectiveCaseMap in .prettierrc instead of CLI to avoid shell quoting issues.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier-plugin-blade'
Plugin is not installed or not in node_modules
fix
Run npm install --save-dev prettier-plugin-blade
The 'parser' option is not recognized by Prettier
Parser string is not 'blade' or plugin not loaded
fix
Ensure plugin is in 'plugins' array and parser is 'blade'. Example: { plugins: ['prettier-plugin-blade'], parser: 'blade' }
Error: Cannot find module '@prettier/plugin-php'
PHP formatting is enabled but optional plugin not installed
fix
Install @prettier/plugin-php: npm install --save-dev @prettier/plugin-php, or disable PHP formatting by setting bladePhpFormatting: 'off'
TypeError: Cannot read properties of undefined (reading 'blade')
Outdated version of Prettier (v2) incompatible with plugin v3
fix
Upgrade Prettier to v3: npm install prettier@^3 --save-dev
Upgrade
Version history
3.1.5latest on npm
Audit
Dependencies
prettierrequiredPeer dependency: required to run the plugin
@prettier/plugin-phpoptionalOptional: enables PHP formatting within Blade templates
prettier-plugin-tailwindcssoptionalOptional: enables Tailwind CSS class sorting
Agent activity
3 hits · last 30 days
node
2
Amazon
1
Resources
prettier-plugin-blade — npm install prettier-plugin-blade · libregistry