Same for me, I managed to solve it with:

    {
        "editor.formatOnSave": true,
        "editor.formatOnPaste": true,
        "editor.formatOnType": true,
        "editor.defaultFormatter": "esbenp.prettier-vscode",
        "[html]": {
            "editor.defaultFormatter": "vscode.html-language-features"
        }
    }

This allowed me to use prettier globally and use built in html formatter for html. Also allowed the formatting to happen on save and while typing.

The part responsible for Prettier formatting html:

  "[html]": {
            "editor.defaultFormatter": "vscode.html-language-features"
        },

To open type Ctrl+Shift+P, then type open user/workspace settings JSON in the command line.

Answer from Eslam Sameh Ahmed on Stack Overflow
🌐
Reddit
reddit.com › r/vscode › prettier extension not working on html files
r/vscode on Reddit: Prettier extension not working on HTML files
January 29, 2022 -

I have Prettier setup as the default formatter already and it's working fine for JSX and JS files.

The weird thing is that it works on save, so when I save it formats HTML correctly, but if I try to do it manually I get: "Extension 'Prettier - Code formatter' is configured as formatter but it cannot format 'HTML'-files".

🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-format-code-with-prettier-in-visual-studio-code
Format Code with Prettier in Visual Studio Code: Setup Guide | DigitalOcean
August 1, 2025 - Note: If you do not see a prompt for selecting a default formatter, you can manually set Prettier as the default formatter in VS Code. Open your Settings and set Editor: Default Formatter to esbenp.prettier-vscode.
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 2478
Prettier not used on HTML even though its the default formatter · Issue #2478 · prettier/prettier-vscode
March 24, 2022 - I've configured prettier as my default formatter in workspace settings. It does work flawlessly with JS and JSON files, but HTML isn't being formatted by prettier. Apparently vscode falls back to the builtin HTML Language Features.
Author   mmarseu
🌐
Prettier
prettier.io › docs › editors
Editor Integration · Prettier
prettier-vscode can be installed using the extension sidebar – it’s called “Prettier - Code formatter.” Check its repository for configuration and shortcuts.
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 3241
Prettier-VSCode doesn't format selections in HTML documents · Issue #3241 · prettier/prettier-vscode
December 20, 2023 - An error pops up with the following text: Configure Default Formatter Extension 'Prettier - Code formatter' is configured as formatter but it cannot format 'HTML'-files Sometimes, usually right after starting VSCode, the error does not appear, but the command still does nothing.
Author   markchagers
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 636
Add the missing option to disable crappy Prettier VSCode HTML formatter · Issue #636 · prettier/prettier-vscode
October 6, 2018 - Format on save messes up original HTML file format · This way I can either stop using VSCode Format on Save or disable Prettier - Code formatter VSCode extension.
Author   micobarac
Find elsewhere
🌐
Salesforce Developers
developer.salesforce.com › docs › platform › sfvscode-extensions › guide › prettier.html
Prettier Code Formatter | Salesforce Extension Pack Features | Salesforce Extensions for Visual Studio Code | Salesforce Developers
After creating the local configuration file, install the Prettier extension for VS Code. If you want to ensure that all your files are formatted whenever you save them, enable the editor.formatOnSave setting in your User and Workspace Settings. You can use Prettier with a pre-commit tool to ...
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 646
HTML Suddenly formatting improperly · Issue #646 · prettier/prettier-vscode
November 20, 2018 - Prettier is suddenly formatting html in a strange way, adding closing slashes to <hr> elements, dropping brackets/carats to the next line, leaving single > on their own line.
Author   silverjerk
🌐
GitHub
github.com › prettier › prettier-vscode
GitHub - prettier/prettier-vscode: Visual Studio Code extension for Prettier · GitHub
Search for Prettier - Code formatter · Visual Studio Code Market Place: Prettier - Code formatter · Can also be installed in VS Code: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter. ext install esbenp.pre...
Starred by 5.5K users
Forked by 509 users
Languages   TypeScript 78.3% | JavaScript 20.3% | PHP 0.6% | Dockerfile 0.3% | HTML 0.3% | SCSS 0.1%
🌐
GitHub
github.com › Shopify › prettier-plugin-liquid › discussions › 162
Format `.html` files in VS Code? · Shopify/prettier-plugin-liquid · Discussion #162
{ "files.associations": { "*.html": "liquid", "*.md": "liquid" }, "[liquid]": { "editor.defaultFormatter": "Shopify.theme-check-vscode", "editor.formatOnSave": true } }
Author   Shopify
Top answer
1 of 1
6

Correct Prettier Extension


There are many prettier extensions to choose from, but only one is the official prettier extension that was written by the same people who maintain prettier. You want to make sure that you have the OFFICIAL PRETTIER EXTENSION.

  • HERE IS THE LINK TO THE OFFICIAL PRETTIER EXTENSION

  • To verify that it is the official extension, its unique extension ID will be: "esbenp.prettier-vscode".

  • The link shows the official extensions page in the Visual Studio website view, you will probably want to download it inside of your editor as opposed to installing it via a VSIX file.



  • You need to configure your default formatter in a generalized way to be able to format JavaScript & HTML. Your trying to specify configurations on a per language basis, which is usually the wrong thing to do if your trying to configure a formatter to format more than one language or file type. You just want prettier to be set as the default formatter, as opposed to the default formatter for HTML, there is a big difference between the two. One formats all languages, the other formats HTML only. for all of VS Code.

  • We also want to make sure that prettier is the formatter we are equipping. Currently you don't have the correct formatter configured. Your trying to use VS Codes Languag-features formatter to get the Prettier formatter to work.


I have included two examples of configuring your default formatter below.
  1. The first example shows the improper configuration that you are currently using. Which configures the formatter specific to a file extension, and it is configuring the wrong formatter

  2. The second configuration is the CORRECT CONFIGURATION TO USE. It configures the Official Prettier Formatting Extension for all of VSCode.



#1

The example below shows what NOT to do!
    /** @file "settings.json" */

    {
        "[html]": {
           "editor.defaultFormatter": "vscode.html-language-features"
    }

The incorrect configuration above does two things wrong.

  1. "vscode.html-language-features" is not the correct extension ID. You need to use the prettier formatter's extension ID. The Prettier extension id is as follows "esbenp.prettier-vscode"

  2. Your configuring the formatter to work for HTML files only.

    • "[HTML]":{ // settings ... } <-- adding prettier to that block configures prettier to only work if a file extension ends in HTML. The problem is, HTML doesn't always get placed in an .html document.

For the context of this question, it isn't technically wrong, but its not the best configuration to use when trying to troubleshoot the issue, instead; you should just set your default formatter as Prettier across all languages. Then once you get Prettier working, you can use settings that specify the languages you want to use it for, and languages you don't want to use it for.



#2

This snippet shows the CORRECT configuration to use
  /** @file "settings.json" */

  {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
      "editor.formatOnSave": true,
  }

Notice that I added format on save? You want that so when you press CTRL + S your code is formatted.



Another thing you don't want to do is configure prettier in your settings.json file.

DONT DO THIS

/** @file "settings.json" */

{
    "prettier.arrowParens": "avoid",
    "prettier.jsxBracketSameLine": true,
    "prettier.bracketSpacing": true,
    "prettier.embeddedLanguageFormatting": "auto",
    "prettier.htmlWhitespaceSensitivity": "css",
    "prettier.insertPragma": false,
    "prettier.jsxSingleQuote": true,
    "prettier.printWidth": 100,
    "prettier.proseWrap": "preserve",
    "prettier.quoteProps": "as-needed",
    "prettier.requirePragma": false,
    "prettier.semi": true,
    "prettier.singleQuote": false,
    "prettier.tabWidth": 2,
    "prettier.trailingComma": "es5",
    "prettier.useTabs": true,
    "prettier.vueIndentScriptAndStyle": false,
}

WHAT YOU WANT TO DO TO CONFIGURE PRETTIER, IS ADD A .prettierrc CONFIGURATION FILE TO EVERY PROJECT.


  1. The prettier configuration file is named ".prettierrc"

  2. The .prettierrc file should be placed in the ROOT directory of your project.

  3. Add the following to your ".prettierrc" document.

{
  "trailingComma": "es5",
  "tabWidth": 4,
  "semi": false,
  "singleQuote": true
}

Here is the link to Prettier's page that shows all available configurations you can add to your prettier file.

At this point Prettier should be working

If prettier isn't working, then you are going to need to get the debugging information about why it isn't working from the prettier extension. Prettier outputs this information for you, but you have to know how to get it.



Getting Debugging Info from the V.S. Code Prettier Extension


NOTE: Stack overflow requires debugging details for every question about an issue. If prettier isn't working getting these debugging details will help you ask your question without people giving you to hard of a time on here.

Add the following setting to your settings.json file

"prettier.enableDebugLogs": true

then open your terminals panel, but instead of using the terminal, your going to click on the OUTPUT option at the top of the panel instead, then in the drop down to the right, select prettier from the menu. This will tell you what is happening each time prettier tries to format.

If your still stuck, get to this point, where you have started to debug/troubleshoot prettier, and comment below about what the debugging info says, or ask a new question and include the debugging info.



END OF EDIT

🌐
TMS Outsource
tms-outsource.com › home › how to use prettier in vscode to format code
How to Use Prettier in VSCode to Format Code
December 18, 2025 - Check status bar: Look for “Prettier” in the bottom right corner of VSCode · Verify config detection: Click “Prettier” in status bar; it should show your .prettierrc path · Test ignore file: Open a file in nodemodules; formatting should not apply · Issue: Files do not format when you press Ctrl+S. ... Issue: ESLint and Prettier fight over formatting rules. ... Issue: Prettier ignores your .prettierrc settings. ... Issue: Prettier works for JavaScript but not HTML or CSS.
🌐
Medium
medium.com › @karimhasibuan › how-to-force-prettier-html-formatting-to-format-tags-in-one-line-this-is-it-f0bf2a50a5b0
How to Force Prettier HTML Formatting to Format Tags in One Line? This is it! | by Karim Hasibuan | Medium
November 28, 2022 - If you don’t have the file, you can create this file with the name of file is .prettierrc.json in your root project directory. After that, you can add some code like this: { // Other options... "overrides": [ { // change .html with .vue if you are using Vue files instead of HTML "files": "src/**/*.html", "options": { "printWidth": 140 } } ] }
🌐
Matthewseiwert
matthewseiwert.com › code › html › auto-format-code-vscode-prettier
Auto Format Code in Visual Studio Code Using Prettier
Learn how to use Prettier in VS Code to automatically align and format your code on save. Perfect for JavaScript, HTML, CSS, and more.
🌐
YouTube
youtube.com › coding with adam
How to use Prettier in VS Code - Code Formatting - YouTube
In this video I will show you how to install and configure Prettier Code Formatter in VS Code. Formatting code consistently can be a challenge, particularly...
Published   January 12, 2022
Views   311K
🌐
Gleb Bahmutov
glebbahmutov.com › blog › configure-prettier-in-vscode
How to configure Prettier and VSCode | Better world by better software
April 23, 2024 - Prettier can format many languages: JavaScript, JSON, Markdown, HTML, CSS, etc. Here is formatting CSS for example. You can configure Prettier and its VSCode extension to format your JSON files. Since there is already a default JSON formatter built into VSCode, you need to tell VSCode to ...
🌐
SheCodes
shecodes.io › athena › 9830-how-to-use-prettier-in-vs-code
[VS Code] - How to Use Prettier in VS Code - SheCodes | SheCodes
Learn how to use Prettier in Visual Studio Code by checking the extention installation, enabling and configuring it. Follow these steps to get your set up! ... when I try to use Visual Studio Vode, I save my index.html, and when I click twice, and I type my code, nothing appears on my index.html, anyone knows why?