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'

Answer from npc2b on Stack Overflow
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
Extension for Visual Studio Code - Beautify code in place for VS Code
🌐
Visual Studio Code
code.visualstudio.com › docs › editing › codebasics
Basic editing
November 3, 2021 - Being able to keep your hands on the keyboard when writing code is crucial for high productivity. VS Code has a rich set of default keyboard shortcuts as well as allowing you to customize them.
🌐
W3Schools
w3schools.io › editor › vscode-format-code
How to format or beautify code in Visual Studio Code tutorials - w3schools
Step by Step guide to auto-format code on saving manually or automatically in Visual Studio code VSCode shortcut commands and workspace settings tutorials. Format a code is a beautify source code on code editor using automatically on save or manually with shortcut command.
🌐
Sentry
sentry.io › sentry answers › vs code › format code in visual studio code
Format code in Visual Studio Code | Sentry
To format the contents of the current file, we can either use the shortcut Ctrl+Shift+I (Command+Shift+I on macOS) or bring up the command palette with Ctrl+Shift+P (Command+Shift+P on macOS) and then search for and execute “Format Document”.
🌐
Carl de Souza
carldesouza.com › home › posts › how to beautify a javascript file in visual studio code
How to Beautify a JavaScript File in Visual Studio Code - Carl de Souza
September 11, 2020 - First, let’s create a really simple JavaScript file. We can see the function is on one line: Search for and select Beautify: Click Install: Now, select CTRL + SHIFT + P or the ...
Find elsewhere
🌐
GitHub
github.com › remarkjs › vscode-remark
GitHub - remarkjs/vscode-remark: Lint and format markdown code with remark · GitHub
To make vscode-remark the default formatter for markdown, add the following to your settings.json (which you can open with Ctrl + ,):
Starred by 65 users
Forked by 13 users
Languages   JavaScript
🌐
GitHub
gist.github.com › muta1 › a53311cfbdf6a02efcf17b760d5e4406
vscode: beautify with shortcut ctrl+s - file: keybindings.json · GitHub
vscode: beautify with shortcut ctrl+s - file: keybindings.json · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
YouTube
youtube.com › watch
How To Beautify Visual Studio Code Tutorial - YouTube
How To Beautify Visual Studio Code TutorialToday we talk about beautify in vs code,visual studio code,beautify,vscode tutorial
Published   February 19, 2023
🌐
DZone
dzone.com › coding › tools › setting custom shortcuts in visual studio code
Setting Custom Shortcuts in Visual Studio Code
July 23, 2016 - In Visual Studio, the shortcut for Code Formatting is Ctrl+k Ctrl+D but in Visual Studio Code, it's Shift+Alt+F.
🌐
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.
🌐
Mkyong
mkyong.com › home › vscode › how to format source code in visual studio code (vscode)
How to format source code in Visual Studio Code (VSCode) - Mkyong.com
November 4, 2021 - formatting vscode, shortcuts, Windows `Shift + Alt + F`, macOS `Shift + Option + F` and Linux `Ctrl + Shift + I`
🌐
GitHub
github.com › HookyQR › VSCodeBeautify
GitHub - HookyQR/VSCodeBeautify: Enable js-beautify (https://github.com/beautify-web/js-beautify) in VS Code · GitHub
Use the following to embed a beautify shortcut in keybindings.json.
Starred by 607 users
Forked by 184 users
Languages   JavaScript
🌐
LinkedIn
linkedin.com › pulse › visual-studio-code-auto-format-shortcut-key-billour-ou
Visual studio code auto format code with shortcut key
February 14, 2023 - Visual studio code's shortcut key for each OS. On Windows : Shift + Alt + F On MAC OS: command + k + f On Ubuntu : Ctrl + Shift + I VS Code has great support for source code formatting.
🌐
GitHub
github.com › Kong › insomnia › issues › 1915
[Feature Request] Keyboard shortcut for Beautify · Issue #1915 · Kong/insomnia
November 29, 2019 - I suggest Shift+Alt+F as it's not taken yet, can be memorized as "format", it's reachable with just the left hand – and my formatting plugin for Visual Studio Code uses the same shortcut 😉 Alternatively I could see Ctrl+B ("beautify") work ...
Author   hellp
🌐
Microsoft Learn
learn.microsoft.com › en-us › dynamics365 › business-central › dev-itpro › developer › devenv-al-formatter
AL Formatter - Business Central | Microsoft Learn
In an existing project, open the document that you want to format, right-click inside the document, and select Format Document. In the default configuration for Visual Studio Code, the command can be run using the shortcut Alt+Shift+F.
🌐
Medium
medium.com › nybles › how-to-beautify-vs-code-e5c74f7144bc
How to beautify VS Code. Well this arc begins like it did for… | by Shailesh Tiwari | Nybles | Medium
December 11, 2021 - How to beautify VS Code Well this arc begins like it did for the first cavemen who saw each other smashing heads with sticks and quickly sought bigger sticks than their bretheren. I was on YouTube …