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.

🌐
Nullneuron
gigi.nullneuron.net › home › formatting json in visual studio code
Formatting JSON in Visual Studio Code - Gigi Labs
December 2, 2022 - Let’s start with the simple scenario: you have a .json file open in VS Code. All you have to do is right-click and select the “Format Document” option (or use the keyboard shortcut, Ctrl+Shift+I:
Discussions

Is there a way to 'prettify' JSON in my console output in my terminal? Just curious
I use https://www.npmjs.com/package/pretty-format if I recall correctly. The colors do indeed help. More on reddit.com
🌐 r/vscode
10
7
October 31, 2018
How can I prettify code/json?
You can configure custom formatter using the setting.json { "JSON": { "format_on_save": { "external": { "command": "whater-command-you-want", "arguments": [ "{file}" ] } } } } I would recommand install https://biomejs.dev/ globally, then you put the command for biome in there. Like you can add this below inside of command, or you can just run prettier. npx @biomejs/biome format --write More on reddit.com
🌐 r/ZedEditor
1
2
April 8, 2023
What is your favorite JSON editor extension?
What's wrong with native support? More on reddit.com
🌐 r/vscode
10
7
December 30, 2020
Setting or feature where I can print json to the Code output or terminal, and I can minimize/collapse segments of the json object?
Where are they coming from? If you're printing them in the browser, under dev tools in Chrome a simple console.log of the object will give you a collapsible version. More on reddit.com
🌐 r/vscode
2
1
September 18, 2023
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-format-json-in-vscode
How to Format JSON in VSCode - GeeksforGeeks
July 23, 2025 - Formatting JSON in VSCode is straightforward and can be achieved through various methods, including built-in tools, command palette, and extensions like Prettier. Properly formatted JSON enhances readability and maintainability, making it an essential practice for developers.
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
vscode-pretty-json - Visual Studio Marketplace
Visual Studio Code>Formatters>vscode-pretty-jsonNew to Visual Studio Code?
🌐
Visual Studio Code
code.visualstudio.com › docs › languages › json
Editing JSON with Visual Studio Code
November 3, 2021 - JSON schemas describe the shape ... by the JSON language support to provide completion proposals. If you are a schema author and want to provide even more customized completion proposals, you can also specify snippets in the schema. The following example shows a schema for a keyboard shortcut settings file ...
Find elsewhere
🌐
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 - 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 › mohsen1 › vscode-prettify-json
GitHub - mohsen1/vscode-prettify-json: Visual Studio Code Prettify JSON Extension · GitHub
October 21, 2020 - Install via package manager. Hit F1 or "cmd+shift+p" and type install and then type Prettify JSON and hit enter.
Starred by 28 users
Forked by 8 users
Languages   TypeScript
🌐
GitHub
github.com › mohsen1 › vscode-prettify-json › blob › master › README.md
vscode-prettify-json/README.md at master · mohsen1/vscode-prettify-json
Install via package manager. Hit F1 or "cmd+shift+p" and type install and then type Prettify JSON and hit enter.
Author   mohsen1
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Visual Studio Code Prettify JSON Extension
December 9, 2015 - Visual Studio Code>Other>Prettify JSONNew to Visual Studio Code?
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
JSON formatter - Visual Studio Marketplace
Extension for Visual Studio Code - Convert file to file type json and format content.
🌐
Woman on Rails
womanonrails.com › visual-studio-code
Visual Studio Code
June 5, 2020 - Ctrl + Shift + I - pretty JSON included directly in VS Code, to use this JSON formatting you need to set JSON file extension or select JSON language mode ... Ctrl + Shift + D - duplicate line(s), (this is shortcut I added to my VS Code), when ...
🌐
GitHub
github.com › vthiery › vscode-prettify-selected-json
GitHub - vthiery/vscode-prettify-selected-json: Visual Studio Code Prettify Selected JSON Extension · GitHub
Install via package manager: hit F1 or "Ctrl + Shift + P", type install and then type Prettify Selected JSON and hit enter.
Author   vthiery
🌐
ClearInsights
clearinsights.io › home › our blog › solved: visual studio code format json
Solved: Visual studio code format JSON - ClearInsights
March 18, 2023 - You can also find the shortcut along with other shortcuts through the submenu View / Command Pallete , also provided in the editor with Ctrl +Shift+ P (or Command + Shift + P on Mac) and then searching for format document.
🌐
DEV Community
dev.to › nabbisen › vs-code-built-in-formatter-for-js-ts-json-html-1lhk
VS Code: Built-in Formatter for .js / .ts / .json / .html - DEV Community
December 26, 2021 - #vscode #formatter #text #manipulation · As Visual Studio Code says in its website: VS Code has has default formatters for JavaScript, TypeScript, JSON, and HTML. The keyboard shortcut: [Ctrl] + [Shift] + i · brings formatted text. Like this ...
🌐
Phil Seamark on DAX
dax.tips › home › use visual studio code to auto-format json
Use Visual Studio Code to Auto-format JSON - Phil Seamark on DAX
October 21, 2020 - Here is a simple example showing how you can create an empty file and paste in some JSON text.
🌐
The Data School
thedataschool.co.uk › zoe-reed › hot-tips-for-formatting-json-in-vs-code
Hot Tips for Formatting JSON in VS Code - The Data School
November 3, 2021 - Simply hold CTRL + K + 0 to collapse the JSON: Before: After pressing CTRL + K + 0: Then we can expand out one-by-one by clicking on the arrows at the start of each line to make sense of the JSON data: For when newly input JSON data isn't being ...