PHPackages                             joelstein/blade-formatter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. joelstein/blade-formatter

ActiveProject[Templating &amp; Views](/categories/templating)

joelstein/blade-formatter
=========================

Format Blade templates and Livewire SFCs with Pint, Tailwind class sorting, and auto-indentation

v0.8.1(2mo ago)5467↑12.5%MITPHPPHP ^8.2

Since Mar 22Pushed 1mo agoCompare

[ Source](https://github.com/joelstein/blade-formatter)[ Packagist](https://packagist.org/packages/joelstein/blade-formatter)[ RSS](/packages/joelstein-blade-formatter/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (13)Versions (41)Used By (0)

Blade Formatter
===============

[](#blade-formatter)

A tool that formats Blade templates and Livewire Single File Components. Like [Laravel Pint](https://laravel.com/docs/pint) for Blade — run a single command and your files are clean. Includes a VS Code extension with format-on-save and automatic PHP/Blade language switching.

What It Does
------------

[](#what-it-does)

Blade Formatter runs three formatters in sequence:

1. **PHP formatting** — Formats PHP in Livewire SFC sections and `@php`/`@endphp` blocks using Laravel Pint
2. **Blade indentation** — Auto-indents Blade templates with proper nesting for directives, HTML, components, and Alpine.js attributes
3. **Tailwind class sorting** — Sorts Tailwind CSS classes using Prettier with [prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)

Each formatter can be enabled or disabled independently. Markdown mail templates (``) are automatically skipped to preserve whitespace-sensitive formatting.

Why Not Prettier?
-----------------

[](#why-not-prettier)

Blade Formatter only changes leading whitespace. It re-indents, but doesn't reflow. Line breaks are left as written.

Other tools, including `pint --blade`, run Blade through Prettier, which also joins short lines, wraps at a print width, and moves attributes onto their own lines. That works well for plenty of projects. A few reasons Blade Formatter doesn't:

- HTML whitespace can be meaningful in ways JSX whitespace usually isn't, so rewrapping sometimes changes what renders.
- Blade mixes PHP and HTML, and how a template reads best tends to depend on what it's doing more than on a fixed width.
- Line length and attributes-per-line are things developers reasonably disagree about.
- Blade components are often one deeply nested tree, since there's no easy way to define and reuse smaller components within a single file. A tall component is fine, since it folds in the editor, but wrapping compounds at every level of nesting.

Mostly this is preference. If you'd rather have full reflow, `pint --blade` does it well.

Skipped Files
-------------

[](#skipped-files)

Some Blade files are never formatted, because reformatting them would change what they do rather than just how they look:

FileWhy`Envoy.blade.php`, `envoy.blade.php`Indentation inside `@task` is passed through to the shell`resources/boost/guidelines/**`Whitespace-sensitive MarkdownTemplates containing ``Whitespace-sensitive Markdown mailThese are skipped even when named explicitly on the command line.

### Opting Out

[](#opting-out)

Wrap a region in `blade-formatter-disable` / `blade-formatter-enable` comments to leave it byte-for-byte unchanged. Everything outside the region is still formatted:

```

    {{-- blade-formatter-disable --}}
    &lt;x-button class="p-4 flex gap-2"&gt;Save&lt;/x-button&gt;
    {{-- blade-formatter-enable --}}

```

Omit the closing comment to opt out the rest of the file. Put one at the top and the whole file is skipped.

Class attribute order never affects CSS, so Tailwind sorting is normally safe everywhere, including inside `@verbatim` where Vue and Handlebars templates genuinely want it. The exception is markup that is itself the content: documentation pages showing code samples, or fixtures asserted against as strings. Sorting rewrites the example you are demonstrating, even when it is HTML-escaped inside ``.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Node.js (for Tailwind class sorting)

Installation
------------

[](#installation)

```
composer require joelstein/blade-formatter --dev
npm install -D prettier prettier-plugin-tailwindcss

# VS Code extension (optional)
code --install-extension vendor/joelstein/blade-formatter/builds/blade-formatter.vsix
```

The VS Code extension requires the [Laravel](https://marketplace.visualstudio.com/items?itemName=laravel.vscode-laravel) extension.

Usage
-----

[](#usage)

```
# Format all Blade files
vendor/bin/blade-format

# Format specific files or directories
vendor/bin/blade-format resources/views/components

# Check formatting without making changes (for CI)
vendor/bin/blade-format --test

# Stop on first file that would change (for CI)
vendor/bin/blade-format --bail

# Fix files, but still exit non-zero if anything changed (for CI)
vendor/bin/blade-format --repair

# Only format files changed since a branch
vendor/bin/blade-format --diff=main

# Only format files with uncommitted changes (including untracked)
vendor/bin/blade-format --dirty
```

Configuration
-------------

[](#configuration)

Create a `blade-formatter.json` in your project root:

```
{
    "paths": ["resources/views"],
    "exclude": [],
    "indent_size": 4,
    "pint_config_path": null,
    "enable_pint": true,
    "enable_tailwind_sort": true,
    "enable_indentation": true,
    "prettier_path": "node_modules/.bin/prettier"
}
```

VS Code Extension
-----------------

[](#vs-code-extension)

The extension provides format-on-save and automatic PHP/Blade language switching in Livewire SFCs. All settings are under `bladeFormatter.*`:

SettingDefaultDescription`enable``true`Enable or disable the extension`formatOnSave``true`Format Blade files on save`enableLanguageSwitching``true`Switch PHP/Blade language modes in SFCs`executablePath``""`Custom path to `blade-format` binaryFormatting options (indent size, enable/disable formatters, etc.) are configured in `blade-formatter.json` — not in VS Code settings. This keeps CLI and editor output consistent.

> **Note:** If you use the [Laravel Pint](https://marketplace.visualstudio.com/items?itemName=laravel.vscode-laravel) VS Code extension with `Laravel.pint.runOnSave` enabled, Pint will strip `use` statements from SFCs that are only referenced in Blade — undoing the blade formatter's work. Disable Pint's run-on-save for Blade files in your `.vscode/settings.json`:
>
> ```
> {
>   "[blade]": {
>     "Laravel.pint.runOnSave": false
>   }
> }
> ```

CI Integration
--------------

[](#ci-integration)

```
- name: Check formatting
  run: |
    vendor/bin/pint --test
    vendor/bin/blade-format --test
```

License
-------

[](#license)

MIT

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance88

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Recently: every ~8 days

Total

40

Last Release

78d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0059aaf8eed7ca19ce7ed1aa4434990350f92e09b86c9fdf57e98f536ef4c765?d=identicon)[joelstein](/maintainers/joelstein)

---

Top Contributors

[![joelstein](https://avatars.githubusercontent.com/u/152397?v=4)](https://github.com/joelstein "joelstein (50 commits)")

---

Tags

formatterlaravelbladelivewiretailwindPint

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/joelstein-blade-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/joelstein-blade-formatter/health.svg)](https://phpackages.com/packages/joelstein-blade-formatter)
```

###  Alternatives

[laravel/sail

Docker files for running a basic Laravel application.

1.9k212.4M1.4k](/packages/laravel-sail)[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M279](/packages/laravel-ai)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9922.4M142](/packages/roots-acorn)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

79227.1M206](/packages/laravel-mcp)[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k612.7k24](/packages/robsontenorio-mary)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React/Svelte) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

5031.3k](/packages/erag-laravel-lang-sync-inertia)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
