SwiftVecto SwiftVecto SwiftVecto

Search Results

No matching tools found

Try searching with a different keyword or browse one of our tool categories.

↑ ↓ Navigate Enter Open Esc Close

Laravel Blade Formatter

Format and beautify Laravel Blade templates with support for Blade directives, components, echo expressions and HTML directly in your browser.

Format Laravel Blade

Beautify Blade templates with support for directives, components, echo expressions and embedded HTML.

Indentation

Influences when long HTML attributes and Blade expressions are wrapped.

Indentation

4 Spaces

Print Width

120

0 lines 0 characters 0 bytes
0 lines 0 characters 0 bytes

Shortcut: Ctrl/Cmd + Enter to format

Blade Template Overview

Inspect common Laravel Blade structures found in the current template.

Directives

Echo Expressions

Components

Directive Depth

Blade Structure Statistics

Conditionals

Loops

Sections

Includes

Extends

PHP Blocks

Slots

Raw Echoes

Blade Comments

HTML Comments

Laravel Convenience Directives

Counts for common Blade helpers used in forms and conditional attributes.

@csrf

@method

@class

@checked

@selected

@disabled

Template Size

Compare the original Blade source with the formatted result.

Input

0

Lines

0

Characters

0

Bytes

Output

0

Lines

0

Characters

0

Bytes

Blade Formatting Example

Compact Blade

@if($user)

{{ $user->name }}

@if($user->active)Active@endif
@endif

Formatted Blade

@if ($user)

{{ $user->name }}

@if ($user->active) Active @endif
@endif

Blade Layout Structure

@extends('layouts.app') @section('content')

{{ $title }}

@yield('body')
@endsection

Blade Components

Blade components combine HTML-like tags with Laravel-specific attributes and expressions.

{{ $title }} Open Tool

Blade Form Directives

@csrf @method('PATCH') enabled) >

Conditional Classes

$active, 'border-slate-300' => !$active, ]) > {{ $message }}

Use Blade Formatter Instead of HTML Formatter

Plain HTML formatters do not fully understand Laravel directives such as @if, @foreach, @section or Blade component expressions.

Use the Laravel Blade Formatter whenever the source contains Blade-specific syntax.

Formatting Is Not Blade Compilation

The formatter restructures source code for readability. It does not run Laravel's Blade compiler.

A formatted template may still contain missing variables, invalid routes, unavailable components or application-level errors.

Review Complex Conditional HTML

Templates that open an HTML element in one Blade branch and close it in another can be difficult for formatters to interpret reliably.

Review templates with unusual cross-branch HTML structures after formatting.

Raw Blade Echoes Require Care

Blade's normal escaped echo syntax outputs HTML-escaped content by default.

Blade also provides raw echo syntax that bypasses normal HTML escaping. Raw output should only be used with content that is known to be safe.

Private Browser-Based Blade Formatting

Laravel Blade formatting happens directly inside your browser during normal interactive use.

  • No Blade file upload is required.
  • Template source does not need to be sent to SwiftVecto's server.
  • The Blade-aware formatting plugin is loaded only when this tool needs it.
  • Statistics are calculated locally from the source.
  • Blade and PHP source is not intentionally executed by the formatter.

How to Format Laravel Blade Templates

Use the SwiftVecto Laravel Blade Formatter to turn compact or inconsistently indented Blade templates into cleaner, easier-to-read views. It supports common Blade directives, echo expressions, components, slots and embedded HTML.

Overview

Laravel Blade extends HTML with server-side templating syntax such as @if, @foreach, @section, @extends, components and {{ ... }} echo expressions. Because Blade mixes HTML, PHP-like expressions and template directives, ordinary HTML formatters do not fully understand its structure. The SwiftVecto Laravel Blade Formatter uses a Blade-aware Prettier plugin in the browser so templates can be formatted with knowledge of Laravel-specific syntax rather than treating directives as malformed HTML. The tool also provides useful Blade statistics such as directive counts, echo expressions, components, slots, loops, conditionals and approximate nesting depth.

Benefits

Format Laravel Blade templates.
Format Blade directives.
Format Blade echo expressions.
Format Blade components.
Format component attributes.
Format Blade slots.
Format @if and related conditionals.
Format @foreach and other loops.
Format @section and @yield structures.
Format @extends declarations.
Format @include statements.
Format @php blocks.
Format embedded HTML.
Format Tailwind-heavy Blade markup.
Choose two-space indentation.
Choose four-space indentation.
Choose tab indentation.
Control print width.
Improve readability of nested Blade templates.
Inspect Blade directive counts.
Inspect echo-expression counts.
Inspect component counts.
Inspect slot counts.
Inspect conditional counts.
Inspect loop counts.
Inspect section counts.
Inspect include counts.
Inspect comments.
Inspect approximate nesting depth.
Copy formatted Blade directly.
Load a sample Blade template for testing.
No file upload is required.
Designed to run directly inside the browser.

How It Works

Paste or type Laravel Blade markup into the input editor.

Choose the preferred indentation style.

Choose the preferred print width.

Run Format Blade.

The browser loads the Blade-aware formatter only for this tool.

The formatter parses Blade directives, HTML and Blade expressions together.

Nested template structures are indented consistently.

Long HTML attributes may be wrapped according to formatter rules.

Blade-aware statistics are calculated separately from the formatting engine.

The result can be copied directly from the browser.

How to Use This Tool

  1. 1
    Paste Blade markup into the input area.
  2. 2
    Choose two spaces, four spaces or tabs.
  3. 3
    Set the preferred print width.
  4. 4
    Run Format Blade.
  5. 5
    Review the formatted template.
  6. 6
    Inspect Blade structure statistics if useful.
  7. 7
    Copy the formatted result.
  8. 8
    Use Load Sample to test the formatter quickly.
  9. 9
    Use Clear before formatting another template.

Helpful Tips

  • Use this formatter instead of the plain HTML Formatter when Blade directives are present.
  • Blade directives such as @if and @foreach are not ordinary HTML syntax.
  • Blade components such as <x-alert> should be formatted with Blade-aware tooling.
  • Tailwind class lists are ordinary HTML attribute values and can usually be reformatted safely.
  • A formatter is not a Laravel compiler and does not execute the template.
  • Formatting does not verify that referenced components exist.
  • Formatting does not verify that included views exist.
  • Formatting does not validate controller variables.
  • Formatting does not run PHP.
  • Formatting does not test Laravel application behaviour.
  • Complex templates that intentionally split HTML tags across Blade branches should be reviewed carefully.
  • Avoid deeply nested conditional Blade markup where extracting components would make the template clearer.
  • Use Blade components to reduce duplicated markup.
  • Use @class where conditional CSS classes become difficult to read.
  • Use @checked and @selected where they simplify form-state expressions.
  • Review production templates after formatting.

Common Uses

Format a Laravel layout.

Format a Blade component.

Format a reusable form partial.

Format @if and @else blocks.

Format nested @foreach loops.

Format a Tailwind-heavy Blade page.

Format @section and @yield structures.

Format @include statements.

Format Blade component attributes.

Format x-slot markup.

Format authenticated navigation markup.

Format a Laravel dashboard view.

Format Blade copied from an older Laravel project.

Worked Examples

The following examples demonstrate how this tool can be used in realistic scenarios.

Formatting a Blade Conditional

A compact @if / @else / @endif block can be expanded so the HTML inside each branch is consistently indented.

Formatting a Blade Loop

Nested markup inside @foreach can be reformatted while keeping the opening and closing Blade directives aligned.

Formatting a Blade Component

A long <x-ui.card> component containing attributes and nested HTML can be wrapped and indented for readability.

Formatting a Layout

Templates using @extends, @section and @endsection can be reformatted so the section hierarchy is easier to scan.

Formatting Tailwind Markup

Blade templates containing long Tailwind utility-class lists can be reformatted without changing the actual class values.

Common Mistakes

Avoid these common mistakes to achieve the most accurate results.

  • Using a plain HTML formatter for Blade templates.
  • Assuming successfully formatted Blade will definitely compile in Laravel.
  • Expecting the formatter to check whether variables exist.
  • Expecting the formatter to validate route names.
  • Expecting the formatter to validate component names.
  • Expecting the formatter to validate view paths.
  • Expecting formatting to fix application logic.
  • Expecting formatting to detect missing @endif or @endforeach in every case.
  • Mixing opening and closing HTML tags across Blade branches without reviewing the result.
  • Assuming Blade formatting performs PHP syntax analysis equivalent to PHPStan or Laravel Pint.
  • Confusing formatting with linting.
  • Confusing formatting with Laravel compilation.
  • Using deeply nested templates where reusable components would be clearer.
  • Replacing production templates without reviewing formatter output.

Glossary

Definitions of the most important terms used by this tool.

Blade

Laravel's server-side templating language for composing HTML views with directives and expressions.

Directive

Blade syntax beginning with @, such as @if, @foreach, @section or @include.

Echo Expression

Blade output syntax using double curly braces, such as {{ $user->name }}.

Raw Echo

Blade output syntax using {!! ... !!}, which renders content without normal HTML escaping.

Blade Component

A reusable Blade UI element typically invoked using tags such as <x-alert> or <x-ui.button>.

Slot

A named or default content region passed into a Blade component.

Layout

A Blade template that provides shared page structure for other views.

@extends

A Blade directive declaring that a view inherits from another Blade layout.

@section

A Blade directive defining content for a named layout section.

@yield

A Blade directive that outputs content provided by a corresponding section.

@include

A Blade directive for rendering another Blade view inside the current template.

@foreach

A Blade looping directive used to iterate over collections or arrays.

@if

A Blade conditional directive used to render markup according to a condition.

@php

A Blade directive for embedding a block of PHP code inside a template.

Formatter

A tool that rewrites source code using consistent presentation rules without intentionally changing its behaviour.

Prettier

An opinionated code formatter that can be extended through plugins to support additional template languages.

Frequently Asked Questions

What is a Laravel Blade formatter?

A Laravel Blade formatter understands Blade-specific template syntax and reformats it together with the surrounding HTML.

Why not use the HTML Formatter for Blade?

Blade introduces directives, echo expressions and component syntax that plain HTML formatters do not fully understand.

Can this format @if blocks?

Yes. Blade conditional directives can be formatted together with the markup they contain.

Can this format @foreach loops?

Yes. Blade loop directives can be indented and structured more consistently.

Can this format Blade components?

Yes. Blade component tags and nested component content can be formatted.

Can this format x-slot elements?

Yes. Blade slots are part of component markup and can be formatted as part of the template.

Can this format Tailwind-heavy Blade markup?

Yes. Tailwind classes remain ordinary HTML attribute values while the surrounding Blade structure is reformatted.

Does the formatter execute Blade?

No. It works with template source text and does not intentionally execute PHP or render the Laravel view.

Does the formatter run PHP?

No. Formatting does not execute embedded PHP code.

Does this validate Blade syntax?

The formatter may reject or fail on some malformed syntax, but it is primarily a formatter rather than a complete Laravel Blade validator.

Does this check whether Blade variables exist?

No. Variable availability depends on the Laravel controller, route, component or view context.

Does this check whether components exist?

No. Formatting does not inspect the Laravel application container or component classes.

Can this format @php blocks?

Blade-aware formatting can preserve and structure @php blocks, although PHP-specific formatting behaviour depends on the formatter implementation.

Does formatting replace Laravel Pint?

No. Laravel Pint primarily formats PHP source files, while this tool focuses on Blade templates.

Does formatting improve Laravel performance?

No meaningful runtime improvement normally comes from pretty formatting. It is primarily for maintainability and readability.

Can formatting break a Blade template?

Formatting is intended to preserve meaning, but complex or unusual templates should always be reviewed after formatting.

Can this format complete Blade pages and fragments?

Yes. It can be used for complete views, layouts, components or smaller Blade fragments.

Does SwiftVecto upload my Blade template?

The interactive Laravel Blade Formatter is designed to perform normal formatting directly inside your browser.

Is the Laravel Blade Formatter free?

Yes. SwiftVecto provides this developer utility for formatting Laravel Blade templates.

Things to Know

  • The browser implementation uses the installed Blade-aware Prettier plugin.
  • The formatter module should be lazy-loaded only on the Laravel Blade Formatter page.
  • Blade templates mix HTML, Blade directives and expressions, so they should not be processed with the plain HTML parser.
  • The tool is a formatter rather than a complete Laravel compiler or validator.
  • Blade structure statistics are informational and separate from the formatter engine.
  • Normal interactive processing is intended to happen directly inside the browser.

Disclaimer

Successful formatting does not guarantee that a Blade template will compile successfully in every Laravel application.

Formatting does not verify routes, components, includes, variables or application logic.

Formatting does not execute PHP or Blade templates.

Unusual templates that split HTML structures across conditional Blade branches should be reviewed carefully after formatting.

Users should review important production templates before deployment.

Official References

The following official resources were used when developing this tool and are useful for further reading.

We use cookies

SwiftVecto uses cookies to improve your experience and support free tools through advertising. Privacy Policy · Cookie Policy