Format on Save automatically formats your code every time you save a file. When it stops working, the cause is usually one of three things: the setting is turned off, no formatter is installed for your language, or multiple formatters are installed and VS Code does not know which one to use.
Check the basic setting first
The simplest fix is also the most common one. Open Settings, search for format on save, and make sure Editor: Format On Save is checked.
Also check that you have not accidentally disabled it for a specific language. In your settings, search for formatOnSave and scroll through all results. Look for entries under language-specific sections like [javascript], [python], or [html]. A language-scoped setting of false overrides the global true.
Use the Settings editor or settings.json; there is no general Format on Save toggle command in the Command Palette.
Install a formatter for your language
VS Code has built-in formatters for JavaScript, TypeScript, JSON, HTML, and CSS. Other languages can receive formatting support from language or formatter extensions.
In Extensions, search for category:formatters, as described in the official formatting documentation. Before installing an extension, verify its publisher, supported languages, pricing, permissions, privacy information, workspace-trust behavior, and local or remote availability on its Marketplace page.
After installing a formatter, test it manually with Shift+Alt+F on Windows, Ctrl+Shift+I on Linux, or Shift+Option+F on macOS. If the document changes without an error, the formatter works and the remaining issue is save-time configuration.
Pick a default formatter
When multiple formatters are available for the same language, choose the one VS Code should use by default.
Open a file of the language that is not formatting. Run Format Document With..., then select Configure Default Formatter... and choose the intended formatter.
Then open the Command Palette again and run Format Document (without "With"). This uses your default choice. If it works, your formatter is correct and you just needed to select it.
For language-specific control in settings.json, keep the entry inside the root object. This example enables the currently selected default formatter for JavaScript without naming a third-party extension:
{
"[javascript]": {
"editor.formatOnSave": true
}
}Check the formatter output log
If Format on Save is enabled and a formatter is selected but nothing happens when you save, the formatter itself may be failing silently. Open the Output panel and select the formatter's output channel from the dropdown.
Select the channel provided by your active formatter, if it has one. Look for messages about:
- "Cannot find module": the formatter's dependencies are not installed
- "SyntaxError": the file has invalid syntax the formatter cannot parse
- Configuration errors: the formatter's config file has issues
Do not create a configuration file unless that formatter's documentation requires one. First fix the specific path, syntax, or dependency error reported by the formatter.
Check for conflicting settings
A few rarely-changed settings can quietly override Format on Save:
- Editor: Format On Paste and Editor: Format On Type are separate features. Having them off does not affect Format on Save.
- Files: Auto Save also saves files. Test once with an explicit File > Save action to make the timing and result easy to observe.
- Workspace settings or
.vscode/settings.jsonin the project can override user settings. Open the file and check for format-related overrides.
If the workspace contains an .editorconfig or formatter-specific configuration file, check whether the active formatter reads it. Formatter behavior is extension-specific, so use that formatter's documentation rather than assuming every formatter applies the same files.
Finally, change indentation in the active file and save it. The fix is complete when the file changes to the chosen formatter's style without an error. For a focused setup walkthrough, see how to enable Format on Save, and use the settings.json guide when checking workspace overrides.
Rune AI
Key Insights
- Make sure editor.formatOnSave is set to true in your settings.
- Install a formatter extension if VS Code does not have a built-in one for your language.
- Use editor.defaultFormatter to pick a formatter when multiple are available for a language.
- Check the Output panel for formatter-specific error messages.
- Look for language-scoped settings like [javascript] that override the global formatOnSave setting.
Frequently Asked Questions
Why does Format on Save work for some files but not others?
How do I know which formatter is being used?
Can I enable Format on Save for only some languages?
Conclusion
Format on Save fails for three main reasons: no formatter is installed for the language, multiple formatters are installed and VS Code needs a default selected, or the formatter itself has an error. Check that editor.formatOnSave is enabled, pick a default formatter for each language, and check the formatter's output log for errors.
More in this topic
How to Use VS Code with WSL 2 on Windows
Run VS Code connected to Windows Subsystem for Linux so you can develop in a full Linux environment with native tools, terminals, and debugging, all from Windows.
20 Best VS Code Extensions for Web Developers in 2026
Twenty carefully chosen VS Code extensions every web developer should know. Covers formatting, linting, frameworks, debugging, Git, and developer experience.
How to Install, Disable, Update, and Uninstall VS Code Extensions
Learn how to install, disable, update, and uninstall VS Code extensions from the Marketplace and the command line. Step-by-step instructions for every action.