Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

coolsaint's avatar

How to Format Laravel Blade Codes in Visual Studio Code ?

I have installed some Visual Studio Code extensions to handle Laravel Blade Codes like

  1. laravel-blade [https://marketplace.visualstudio.com/items?itemName=KTamas.laravel-blade]
  2. Laravel Blade Snippets [https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel-blade]

But they are not helping me to format Laravel Blade Codes [blade.php files]. I mean they are not auto indenting the codes as I expected. But I have seen blade codes online which are well indented in visual studio Code IDE.

Is their any specific configuration or technique which I can use to make these extensions work or there is some other way? Thanks.

0 likes
21 replies
coolsaint's avatar

I have already read the article and installed some of the extensions that might solve my problem like beautify, auto close tags, laravel code snippets and PHP Intellisense - Crane. But still my laravel blade codes are not auto indenting.

I have found this on the github issue page of larave blade snippets :

https://github.com/onecentlin/laravel-blade-snippets-vscode/issues/9

looks like it is not working in others cases too. Did you do any configuration change for blade files handling?

nivv's avatar

Can't get this to work either. There is a PR that onecentlin won't merge with a fix

robertmarriott's avatar

aligilan's solution is a partial work-around. It does format the HTML nicely, but it also places blade directives on a single line like:

@extends('...') @section('...') etc.

However, if you install the "Laravel Blade Snippets" extension and then go to User Settings -> Extensions and look for "Blade Configuration". There's an option to enable formatting. Just check the box and then reload Visual Studio Code.

EDIT: On second thought, you're better off with aligan's solution or, better yet, no auto-formatting at all. The Laravel Blade Snippets extension [really] messes up the formatting.

1 like
jaksidaniel's avatar

after installing Laravel Blade Snippets you must enable formatting blade files in settings search for blade.format.enable

2 likes
JoshuaD's avatar

Some things don't work well, for example the layout that comes with --auth.

@if (Route::has('register'))

turns into

<blade
    if|%20(Route%3A%3Ahas(%26%2339%3Bregister%26%2339%3B))>
devondahon's avatar

I have installed and enabled PHP Blade Snippets, then checked the enable format blade file box for blade.format.enable in VSCode settings, but I can't see any format change when I execute >Format Document. Also, if I execute >Format Document With..., I don't see Laravel Blade Snippet in the list, only PHP Intelephense and php cs fixer.

What might be wrong in my config ?

Zayar's avatar

Aptly beautify blade all most works but there when I use @props() all the code below it gets indented.

xiolog's avatar

This plugin doesn't work anymore.

slovenianGooner's avatar

This is a great extension - if it will be possible to support "beautify.config" settings and it would be amazing.

Something like this in settings would be amazing:

  "beautify.config": {
    "indent_size": 2,
    "wrap_line_length": 140,
    "wrap_attributes": "force-aligned"
  },
1 like
shufo's avatar

@sloveniangooner Thank you! I think it's good idea to support js beautify configs. I'll consider this feature to include in the next version.

Please or to participate in this conversation.