The XML extension, from Red Hat, supports auto-indentation on enter, among many useful other features (like validation, code completion, autoclose tag...):

Answer from Fred Bricon on Stack Overflow
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 1579
Format XML · Issue #1579 · prettier/prettier-vscode
September 29, 2020 - Alternative: How to tell Prettier / VS Code to handle XML like HTML to format the XML as HTML. I think this will work in the very most of cases. For example: I want to format SVG.
Author   infacto
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Pretty XML - Visual Studio Marketplace
Extension for Visual Studio Code - XML formatter extension for Visual Studio Code. Formats XML documents just like Visual Studio.
Discussions

format - XML autoformat in Visual Studio Code - Stack Overflow
Is there a way to make Visual Studio Code automatically format the content of XML tags? I want to have an indent when pressing Enter or even when closing a tag: Not as but this way: More on stackoverflow.com
🌐 stackoverflow.com
Extension for automatic beautification of JSON, XML, etc.
I believe its prettier https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode More on reddit.com
🌐 r/vscode
1
2
March 31, 2023
XML formatting
Hi, Could you please add XML formatting Standard prettier playground easily does this. It's the only tool which formats XML exactly how I need. However VS code doesn't recognize this extens... More on github.com
🌐 github.com
7
June 29, 2018
Issues with prettier-vscode not working properly with plugins since prettier 3.1.0 release
Install the prettier-vscode plugin in vscode, install any plugin, for example prettier-xml, set prettier-xml as the formatter for xml files, configure .prettierrc (or another config file), attempt to use prettier for formatting xml. More on github.com
🌐 github.com
8
February 20, 2024
🌐
GitHub
github.com › prettier › plugin-xml
GitHub - prettier/plugin-xml: Prettier XML plugin · GitHub
You can also use the "preserve" option, if you want to preserve the whitespace of text nodes within XML elements and attributes. See #478 for more detail. You can use two special comments to get prettier to ignore formatting a specific piece of the document, as in the following example:
Starred by 275 users
Forked by 40 users
Languages   JavaScript
🌐
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 - To make sure Visual Studio Code uses Prettier for all formatting operations: Open Settings (JSON) via the Command Palette. ... You can apply this setting globally or in a workspace-specific .vscode/settings.json file.
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 505
XML formatting · Issue #505 · prettier/prettier-vscode
June 29, 2018 - Hi, Could you please add XML formatting Standard prettier playground easily does this. It's the only tool which formats XML exactly how I need. However VS code doesn't recognize this extens...
Author   ThePlenkov
Find elsewhere
🌐
YouTube
youtube.com › watch
Format document using prettier in vscode | Auto format code - JSON, XML, JS, TS, YAML | beautify - YouTube
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera - http://amzn.to/2tVwcMPTripod - http://a...
Published   September 3, 2022
🌐
Prettier
prettier.io
Prettier · Opinionated Code Formatter · Prettier
XML · And more... prettier-js prettier.el Apheleia · espresso-prettier · Prettier Prettier⁺ · JsPrettier · vim-prettier neoformat ALE coc-prettier · JavaScriptPrettier · prettier-vscode · Built-in support · Got more?Send a PR · See others · Regularly used by: More than 83% of respondents to State of JS 2021.
🌐
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
🌐
GitHub
github.com › prettier › prettier › issues › 16102
Issues with prettier-vscode not working properly with plugins since prettier 3.1.0 release · Issue #16102 · prettier/prettier
February 20, 2024 - Install the prettier-vscode plugin in vscode, install any plugin, for example prettier-xml, set prettier-xml as the formatter for xml files, configure .prettierrc (or another config file), attempt to use prettier for formatting xml.
Author   TOnDAhNe
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.

🌐
VsixHub
vsixhub.com › vsix › 33843
Pretty XML 6.1.0 VSIX (Latest Version) - VsixHub
May 22, 2025 - You are about to download the vsix file for Pretty XML v6.1.0 extension on Visual Studio Code 1.99.1 and up: Pretty XML, XML formatter extension for Visual Studio Code. Formats XML documents just like Visual Studio.
Rating: 4.6 ​ - ​ 31 votes
🌐
npm
npmjs.com › package › @prettier › plugin-xml
prettier/plugin-xml
July 8, 2025 - You can also use the "preserve" option, if you want to preserve the whitespace of text nodes within XML elements and attributes. See #478 for more detail. You can use two special comments to get prettier to ignore formatting a specific piece of the document, as in the following example:
      » npm install @prettier/plugin-xml
    
Published   Jul 08, 2025
Version   3.4.2
Author   Kevin Newton
🌐
Reddit
reddit.com › r/xml › prettier xml plugin in vscode
r/xml on Reddit: Prettier XML plugin in VSCode
January 20, 2022 - I've downloaded the Prettier extension for VSCode and added the XML plugin for it.
🌐
Stack Overflow
stackoverflow.com › questions › 67935122 › how-do-i-set-the-default-formatter-for-xml-in-vscode
visual studio code - How do I set the default formatter for XML in VSCode? - Stack Overflow
I trying to format XML in VSCode but every time I hit Shift+Alt+F I get a popup saying "The is no formatter for 'xml' files installed" and offering [Cancel] or [Install Formatter..]. At l...