An opinionated Blade template formatter for Laravel that automatically indents markup inside directives, adds spacing to Blade markers, and supports PHP 8 features (null safe operator, named arguments). It also includes PSR-2 formatting inside directives and automatic Tailwind CSS class sorting. The current stable version is 1.44.4 with regular releases. Key differentiators: dedicated Blade formatter (no official one exists), built-in Tailwind sorting, custom directive support, and an online demo. Ships TypeScript declarations and requires Node >= 14.0.0.
npm install blade-formatterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Formats a Blade template with indentation, Tailwind sorting, and custom directives using ESM import.
Use ES module imports (import { ... } from 'blade-formatter').Rename `sortTailwindcssClasses` to `sortTailwindClasses` in your configuration.
Always pass custom directive names via the `customDirectives` option.
Upgrade to >=1.35.0 or increase Node memory limit (--max-old-space-size).
Remove `formatPhp` from options.
Change import to ES module syntax (import { format } from 'blade-formatter') or use dynamic import.Always pass an options object, even if empty: format('...', {}).Check that all @section/@endsection, @if/@endif etc. are properly paired.
Install prettier: npm install --save-dev prettier.