Recommended Free Tools
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To auto-format code in Visual Studio Code, run Format Document for the whole file or turn on "editor.formatOnSave": true to format whenever you save. If VS Code offers multiple formatters, choose a default for that language first. You can also limit save-time formatting to particular languages, such as Python or TypeScript.
Format a file or selection right now
Open a file in the language you want to format, then use the Command Palette to run Format Document. You can also find the command in the editor context menu. On Windows and Linux, the documented shortcut is Shift+Alt+F; macOS uses the platform’s equivalent shortcut.
To change only highlighted code, select it and run Format Selection. This is useful when you want to tidy a fragment without reformatting the rest of a file. A formatter must support range formatting for selection-based operations.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsChoose a formatter when prompted
If more than one extension can format the current language, VS Code may ask which provider to use. Choose Format Document With…, then Configure Default Formatter… to set the preferred provider for that language. Without a default, the editor may continue asking you to choose or may use a different available provider than you expect.
#1 Best Overall
Turn on format on save
For automatic formatting each time you save, open Settings and search for Format On Save, then enable Editor: Format On Save. The same setting can be added directly to JSON settings. To apply it to every supported language, add this at the top level:
{
"editor.formatOnSave": true
}
Save a file and inspect the resulting changes. If the file does not change, it may already match the formatter’s rules; if it does change, review the diff to confirm that the result fits the project’s conventions.
Enable it only for selected languages
Language-specific settings let you format one language on save without changing the behavior of other files. For example, this Python configuration enables save formatting and selects the Black Formatter extension as the default:
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →{
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "ms-python.black-formatter"
}
}
Use the same bracketed language scope with a different language ID and formatter identifier when the appropriate formatter is installed. For example, a TypeScript block can scope the setting to TypeScript. Do not put the language block inside quotes as a single key with embedded JSON; it needs to be a JSON object, as shown.
Rank #2
Set up a formatter for Python, Go, or TypeScript
Python: install and select a formatter
VS Code’s Python formatting workflow uses a formatter extension. Install the formatter you want, open a Python file, and select it through Format Document With… → Configure Default Formatter…. The official VS Code example uses Black Formatter, whose identifier is ms-python.black-formatter. You can then enable format on save globally or in a [python] language block.
Formatting and import organization are separate tasks. If your goal includes sorting imports, the Python documentation describes configuring Ruff through editor.codeActionsOnSave. Setting a formatter as the default does not, by itself, mean that import sorting is enabled.
Go: use the Go extension’s formatting support
Go formatting is provided through gopls, and the Go extension runs formatting when you save a Go file by default. To disable that behavior, use a language-specific setting:
{
"[go]": {
"editor.formatOnSave": false
}
}
If you want to explicitly choose the Go extension as the formatter, set "editor.defaultFormatter": "golang.go" in the [go] block. This is especially useful when another installed extension also advertises Go formatting.
Rank #3
JavaScript and TypeScript: start with the built-in formatter
VS Code documents built-in formatting support for JavaScript and TypeScript, as well as JSON, HTML, and CSS. TypeScript’s basic formatting behavior can be customized through js/ts.format.* settings. If you have installed another extension for a language, select the intended provider as the default rather than assuming that installing it automatically replaces the built-in formatter.
Understand which settings take effect
When a setting appears correct but formatting does not behave as expected, check where it is defined and whether a more specific setting overrides it. VS Code’s documented precedence runs from default settings through user, remote, workspace, folder, language-specific settings at those scopes, and finally policy settings. In practical terms, a workspace or folder rule can override a user-level preference, and a language-specific rule can override a general rule.
- User settings apply to your VS Code user profile.
- Workspace settings apply to the current project and are commonly stored in
.vscode/settings.json. - Folder settings can further scope behavior in a multi-root workspace.
- Language-specific settings, such as
[python], apply to files identified as that language and can differ by scope.
Open Preferences: Open User Settings (JSON) from the Command Palette to edit user JSON settings. To inspect project configuration, open the workspace’s .vscode/settings.json. The Settings editor can also reveal whether a value is coming from a workspace or another scope.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Know what the formatting triggers do
VS Code has separate settings for formatting on save, while typing, and after pasting. editor.formatOnSave runs on save; editor.formatOnType formats in response to typing; and editor.formatOnPaste formats pasted content. These triggers are off by default in the general formatting workflow. Paste formatting also depends on the formatter supporting range formatting, so enabling the setting alone does not guarantee that every formatter can reformat pasted text.
Rank #4
Choose the trigger that matches your workflow. Save formatting is convenient for whole-file consistency; typing or paste formatting changes code earlier and may not be supported by every language provider. If you want predictable changes, configure a default formatter and inspect the diff when adopting a new setup.
Troubleshoot formatting that does not run
Format Document is missing or does nothing
Confirm that the editor is open on a file VS Code recognizes as the intended language. For languages that rely on extensions, make sure a suitable formatter extension is installed and available. Then run Format Document With… and select a provider. If it reports that no formatter is available, installing or enabling a formatter for that language is the next step.
Save does not format the file
- Check that
editor.formatOnSaveistruein the effective settings scope. - Check the applicable language block, such as
[python]; a language-specific value may override the general setting. - Look for a workspace or folder
.vscode/settings.jsonvalue that takes precedence over your user setting. - Choose a default formatter if multiple providers are installed.
- Run Format Document manually to determine whether the formatter works independently of the save trigger.
VS Code reports invalid settings JSON
Settings JSON must use valid syntax: property names and string values need double quotes, entries need commas between them, and the last property in an object must not have a trailing comma. VS Code highlights errors in settings.json. Open Preferences: Open User Settings (JSON) or use the Settings editor to correct the file. The default-settings file is read-only; use it as a reference for comparing or resetting values, not as the place to enter your own settings.
The wrong extension runs, or extensions conflict
Use Format Document With… → Configure Default Formatter… to choose the provider for that language. If you need a dedicated shortcut to invoke a particular formatter without changing editor.defaultFormatter, VS Code supports binding editor.action.formatDocument.multiple with a formatter identifier. This is a narrower solution for a shortcut conflict; it does not change the default formatter setting.
Paste formatting does not work
Check that editor.formatOnPaste is enabled, then verify that the selected formatter supports range formatting. Paste formatting requires that capability; some providers may support whole-document formatting without supporting ranges.
Choose a formatter that fits the project
A formatter choice affects more than appearance. Compare options using the language and workflow that matter to your team:
- Language coverage: confirm that the formatter supports the languages and file types in the project.
- Whole-file and range support: check whether it can format documents, selections, or pasted ranges as needed.
- Project consistency: consider whether its configuration files let contributors share the same style rules.
- Related code actions: distinguish formatting from tasks such as linting or import sorting; they may need separate configuration.
- Save-time behavior: check whether the extension runs at the desired trigger and whether its changes are acceptable in your workflow.
- Extension maintenance and trust: review the extension’s publisher, maintenance status, and permissions before installing it.
VS Code’s documentation does not establish a universal performance ranking among formatters. The best choice depends on language support, project configuration, range support, and the behavior your team wants on save.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server, not a VS Code code formatter. It will not format source files; it is relevant if you need a screenshot of a website or rendered code page as part of a separate workflow. One GET request captures a URL. See the ScreenshotNeo API documentation for options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python equivalent:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js equivalent:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo removes cookie or consent banners, newsletter popups, and chat widgets before a capture; each of those cleanup steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The Free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan. Find out more at ScreenshotNeo, or sign up free for 1,000 screenshots a month with no card.
Frequently Asked Questions
Does format on save also sort imports?
No. Formatting and import organization are separate operations; configure an appropriate code action for import sorting if you want both.
Can I use different formatters in different projects?
Yes. Workspace settings can specify a formatter and save behavior for a project, subject to any more-specific folder or language settings.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

