Last updated: Apr 6, 2024
Reading time·5 min
The first thing you should check is that Prettier is selected as your default formatter.
Ctrl
+ Shift
+ P
on Windows and LinuxCommand
+ Shift
+ P
on macOSCtrl
+ ,
(or Cmd
+ ,
on macOS) keyboard shortcut to open the settings menu.Make sure that all checkboxes of languages are checked as shown in the following screenshot.
If you can't find the Settings menu, click on:
Alt
to show the top menu on Windows and Linux.Make sure the Format on Save setting is enabled:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.Ctrl
+ ,
(or Cmd
+ ,
on macOS) keyboard shortcut to open the settings menu.The next thing you should try is to click on the prettier icon in the Status Bar at the bottom right corner of the screen.
When you click on the icon, the OUTPUT tag gets focused.
If there are any issues with your Prettier installation or configuration, they are shown in the OUTPUT tab.
If you can't see the prettier button in the Status Bar, right-click on the Status Bar at the bottom and make sure the Prettier option is ticked.
Another thing you should try is to use the Format Document action from the Command Palette:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.If you haven't installed a formatter for the specific file, you will get prompted.
Another thing you can try is to set Prettier as the formatter for the specific file and all other files with the extension.
Open and focus a specific file (e.g. a .js
file).
Press:
Ctrl
+ Shift
+ P
on Windows and LinuxCommand
+ Shift
+ P
on macOSF1
to open the Command Palette.Make sure the Prettier extension is installed and enabled:
Ctrl
+ Shift
+ X
on Windows or LinuxCommand
+ Shift
+ X
on macOSAlso, make sure to install the original Prettier extension that was developed by the Prettier organization.
The next thing you should try is to disable the extension and reenable it.
Once you click on the extension in the left sidebar:
You might get prompted to reload VS Code after disabling the extension.
Another thing you can try is to install the prettier
module locally.
Open your terminal in your project's root directory (where your package.json
file is) and run the following command.
# in case you don't have a package.json file yet npm init -y npm install prettier -D --save-exact
The command installs the prettier module locally.
If the package is installed locally, the extension will use your project's local version.
Otherwise, the version that is bundled with the extension will be used.
Make sure you also have your other modules installed.
# for NPM npm install # for YARN yarn install
Another thing you can try is to restart VS Code:
Ctrl
+ Shift
+ P
on Windows and LinuxCommand
+ Shift
+ P
on macOSF1
to open the Command Palette.Make sure Format on Save Mode is set to file
:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.Ctrl
+ ,
(or Cmd
+ ,
on macOS) keyboard shortcut to open the settings menu.settings.json
file with incorrect configMake sure you don't have a local .vscode/settings.json
file where you've set
editor.formatOnSave
to false
.
For example, the following config would prevent you from formatting your code on save.
{ "editor.formatOnSave": false }
Even if you have format on save enabled globally, the local config in the
.vscode
directory would override the global setting.
Make sure you haven't set formatOnSave
to false
locally in
.vscode/settings.json
.
package.json
file which also takes precedence over your global config.Another thing you can try is to reinstall the Prettier extension:
Ctrl
+ Shift
+ X
on Windows or Linux.Command
+ Shift
+ X
on macOS.