Right-click in your text editing area and choose Format Document With.... A popup will appear on top then choose Choose default formatter and then choose Prettier

Answer from Ayush Gupta on Stack Overflow
Discussions

Help with formatting of my HTML files in VS Code
For some reason, the paragraph content in my HTML files is breaking into multiple lines in VS Code. I made the mistake of making changes to my settings based on a video I watched. I thought I undid the changes I made, but maybe I missed something. And that is assuming the change in the editor ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
December 4, 2021
How do you format code in Visual Studio Code (VSCode)? - Stack Overflow
Linux: $HOME/.config/Code/User... the .vscode folder in your project. More details may be found here. ... But what is the consequence? How will it actually work after the change? Will it immediately / automatically change the formatting as something is typed? Also at paste? 2020-06-13T11:38:43.637Z+00:00 ... A new window opens. Search for "format" and select the option which has formatting as per the requirement. ... By default, this key was not working for me on HTML, CSS, and ... More on stackoverflow.com
🌐 stackoverflow.com
What's your favorite HTML/ERB formatter extension for VSCode?
I'm running ERB Formatter/Beautifier (which uses htmlbeautifier under the hood), plus rufo with this extension to format the actual Ruby code in my ERB views (so I run both formatters sequentially). Works well enough More on reddit.com
🌐 r/rails
10
18
May 29, 2025
What's your approach to auto-formatting your project in VS Code?
Prettier plugin: DO NOT change any of the settings and setup a .prettierrc in your project. Set Prettier as your formatter and format on save. And then thankfully forget about formatting ever again, for you and your team. EDIT: Set your formatter with "Format document with..." > "Configure Default Formatter" More on reddit.com
🌐 r/react
13
2
March 17, 2023
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Prettier - Code formatter - Visual Studio Marketplace
January 21, 2026 - Extension for Visual Studio Code - Code formatter using prettier
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
JS-CSS-HTML Formatter - Visual Studio Marketplace
Extension for Visual Studio Code - Format ,prettify and beautify JS, CSS, HTML code by using shortcuts, context menu or CLI
🌐
Medium
thiraphat-ps-dev.medium.com › the-best-code-formatters-for-vs-code-11704e787f92
The Best Code Formatters for VS Code | by Thiraphat Phutson | Medium
June 3, 2024 - Beautify is another popular code formatter for VS Code that supports various languages such as JavaScript, HTML, CSS, and JSON.
Find elsewhere
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Pretty Formatter - Visual Studio Marketplace
Extension for Visual Studio Code - VS Code extension to format your code using Pretty Diff
🌐
freeCodeCamp
forum.freecodecamp.org › t › help-with-formatting-of-my-html-files-in-vs-code › 487585
Help with formatting of my HTML files in VS Code - The freeCodeCamp Forum
December 4, 2021 - For some reason, the paragraph content in my HTML files is breaking into multiple lines in VS Code. I made the mistake of making changes to my settings based on a video I watched. I thought I undid the changes I made, b…
🌐
GitHub
github.com › mohd-akram › vscode-html-format
GitHub - mohd-akram/vscode-html-format: A Visual Studio Code extension for formatting HTML documents.
A Visual Studio Code extension for formatting HTML documents. - mohd-akram/vscode-html-format
Starred by 12 users
Forked by 3 users
Languages   TypeScript 100.0% | TypeScript 100.0%
🌐
Dirask
dirask.com › posts › VS-Code-format-html-code-D9OAaj
VS Code - format html code
VS Code used to format HTML source code (installed Prettier formatter). VS Code - beautify html code · VS Code - make html code pretty · VSCode - format html code · Donate to Dirask · Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us.
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Format HTML in PHP - Visual Studio Marketplace
Extension for Visual Studio Code - Provides formatting for the HTML code in PHP files using JSbeautify - Works well paired with a PHP formatting extension
🌐
GitHub
github.com › Lonefy › vscode-JS-CSS-HTML-formatter
GitHub - Lonefy/vscode-JS-CSS-HTML-formatter: JS,CSS,HTML formatter for vscode
This extension wraps js-beautify to format your JS, CSS, HTML, JSON file. ... the upper 3 ways don't work for Javascript&JSON after vscode v0.10.10, but you can still format CSS and HTML.
Starred by 50 users
Forked by 23 users
Languages   TypeScript 100.0% | TypeScript 100.0%
🌐
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 - Learn how to format code with Prettier in Visual Studio Code. This guide walks you through installing, configuring, and using Prettier for code formatting.
Top answer
1 of 16
6008

The code formatting is available in Visual Studio Code through the following shortcuts:

  • On Windows Shift + Alt + F
  • On Mac Shift + Option + F
  • On Linux Ctrl + Shift + I

Alternatively, you can find the shortcut, as well as other shortcuts, through the submenu View / Command Palette, also provided in the editor with Ctrl + Shift + P (or Command + Shift + P on Mac), and then searching for format document.

For unsaved snippets

  1. Open command palette (Win: F1 or Ctrl + Shift + P)

  2. Find "Change Language Mode"

  3. Select language e.g. json. By now, the syntax should be highlighted.

  4. Format document (e.g. Open Command Palette -> "Format Document")

Unformat

  1. Select text
  2. Command Palette -> Join Lines

'Show the pics'

2 of 16
607

Code Formatting Shortcut:

Visual Studio Code on Windows - Shift + Alt + F

Visual Studio Code on MacOS - Shift + Option + F

Visual Studio Code on Ubuntu - Ctrl + Shift + I

You can also customize this shortcut using a preference setting if needed.

Code Formatting While Saving the File:

Visual Studio Code allows the user to customize the default settings.

If you want to auto format your content while saving, add the below code snippet in the work space settings of Visual Studio Code.

Menu FilePreferencesWorkspace Settings

{
  // Controls if the editor should automatically format the line after typing
  "beautify.onSave": true,

  "editor.formatOnSave": true,

  // You can auto format any files based on the file extensions type.
  "beautify.JSfiles": [
      "js",
      "json",
      "jsbeautifyrc",
      "jshintrc",
      "ts"
  ]
}

Note: now you can auto format TypeScript files. Check my update.

🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Beautify - Visual Studio Marketplace
May 2, 2019 - Extension for Visual Studio Code - Beautify code in place for VS Code
🌐
GitHub
github.com › squizlabs › PHP_CodeSniffer › discussions › 3941
vs code formatting mixed php and html · squizlabs PHP_CodeSniffer · Discussion #3941
March 5, 2024 - Adjust the settings for PHP and HTML formatting to your preference. For example: "php.format.enable": true, "php.suggest.basic": false, "editor.formatOnSave": true, // Enable format on save "editor.defaultFormatter": "esbenp.prettier-vscode", // Use Prettier as the default formatter ·
Author   squizlabs
🌐
iorad
iorad.com › player › 1691840 › Change-Visual-Studio-Code-Default-Settings-for-HTML-Formatting---Auto-Format-Code-After-Changing
Change Visual Studio Code Default Settings for HTML Formatting - Auto-Format Code After Changing
November 3, 2021 - The first step is to open Visual Studio Code and click File. Highlight Preferences and Click Settings. Click Extensions. Click HTML to change settings for HTML files. Click "Edit in settings.json".