Features
HTML & JavaScript via Prettier
Battle‑tested Prettier formatting for HTML and JavaScript.
PHP via @prettier/plugin-php
Consistent PHP formatting powered by the official Prettier PHP plugin.
Blade via blade-formatter
Purpose‑built Blade formatter designed for Laravel’s templating syntax.
One‑click or on‑save
Run the command or enable editor.formatOnSave to format automatically.
Usage
Command
- PBHJ: Format Document – format the active file
Shortcut: Shift+Alt+P
Auto‑format: enable "editor.formatOnSave": true in settings.
How it works
- HTML, JavaScript →
prettier - PHP →
@prettier/plugin-php - Blade →
blade-formatter
Settings
| Key | Default | Description |
|---|---|---|
pbhjFormatter.printWidth |
100 |
Maximum line width for Prettier‑based formatters. |
pbhjFormatter.tabWidth |
2 |
Spaces per indentation level. |
pbhjFormatter.useTabs |
false |
Use tabs instead of spaces. |
pbhjFormatter.semi |
true |
Print semicolons in JavaScript. |
pbhjFormatter.singleQuote |
true |
Use single quotes in JavaScript. |
pbhjFormatter.blade.wrapAttributes |
"auto" |
Attribute wrapping for Blade (auto, force, force-aligned, force-expand-multiline). |
Compatibility
- VS Code ≥ 1.70.0
- Works with
.html,.js,.php,.blade.php
Troubleshooting
If you encountered “PBHJ Blade format error: fn is not a function”, update to version 1.0.10 or newer and reload VS Code.
Formatting doesn’t run on save
- Ensure
"editor.formatOnSave": trueis enabled. - Make sure this extension is the default formatter for the file type.
Unexpected result in Blade
- Adjust
pbhjFormatter.blade.wrapAttributesto your preferred style. - Reload the window after changing settings.
FAQ
Yes, it uses
prettier, @prettier/plugin-php, and blade-formatter and respects your configuration above..html, .htm, .js, .mjs, .cjs, .php, and .blade.php.Run the command palette and execute PBHJ: Format Document or press Shift+Alt+P.
Ready to format with confidence?
Install the extension and keep your codebase consistent across HTML, JS, PHP, and Blade.