A production-ready Laravel Blade formatter with advanced Blade parsing and Prettier-level indentation.
✨ Features
- Advanced Blade directive parsing (
@if, @foreach, @section, etc.)
- HTML + Blade nesting awareness
- Safe formatting for PHP blocks and echo statements
- Prettier-like consistent indentation
- Supports Format on Save
- Lightweight and fast
📦 Installation
- Open VS Code
- Go to Extensions (
Ctrl + Shift + X)
- Search Laravel Blade Formatter
- Click Install
Or install manually:
code --install-extension laravel-blade-formatter-0.3.0.vsix
🚀 Usage
- Open a
.blade.php file
- Press
Shift + Alt + F
- Or use Command Palette → Laravel Blade: Format Document
{
"editor.formatOnSave": true
}
⚙️ Configuration
{
"laravelBladeFormatter.format.enabled": true,
"laravelBladeFormatter.format.indentSize": 4,
"laravelBladeFormatter.format.wrapAttributes": "auto",
"laravelBladeFormatter.format.wrapLineLength": 120,
"laravelBladeFormatter.format.endWithNewLine": false,
"laravelBladeFormatter.format.sortTailwindcssClasses": false,
"laravelBladeFormatter.format.noMultipleEmptyLines": false,
"laravelBladeFormatter.format.indentInnerHtml": false
}
🧪 Example
Before:
@if($user)
<div>
<h1>{{ $user->name }}</h1>
@foreach($posts as $post)
<p>{{ $post->title }}</p>
@endforeach
</div>
@endif
After:
@if($user)
<div>
<h1>{{ $user->name }}</h1>
@foreach($posts as $post)
<p>{{ $post->title }}</p>
@endforeach
</div>
@endif
🧑💻 Author
Rayhan Bapari
| |