Or simply install Black Formatter from VSC extension menu:

https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter

:)

Answer from Davor on Stack Overflow
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ python โ€บ formatting
Formatting Python in VS Code
November 3, 2021 - Open a Python file in VS Code. Right-click on the editor to display the context menu. Select Format Document With.... Select Configure Default Formatter... from the drop-down menu. Select your preferred formatter extension from the list. Alternatively, you can set it as the default formatter for all Python files by setting "editor.defaultFormatter" in your User settings.json file, under a [python] scope.
Discussions

What are the best VSCode extensions for Python?
Pylance, Black and Intellisense. Would be my top 3. More on reddit.com
๐ŸŒ r/learnpython
33
59
August 21, 2023
formatting - How do you format python code in Visual Studio Code? - Stack Overflow
and then open the auto format option ... python format provider to black in vscode settings. enjoy the black. ... You can use Ruff, it is suggested in the official VSCode documentation. Among their suggestions, it is the highest-rated community extension. Once installed, simply press ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 11 VS Code Python extension (circa v2018.19) no longer includes support for linters and ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
My formatter for Python in VS Code is not working.
I had the same issue and fixed it by installing black-formatter and making sure following in the settings.json: "[python]": { "editor.defaultFormatter": "ms-python.black-formatter" }, More on reddit.com
๐ŸŒ r/AskProgramming
6
4
December 6, 2023
Are there any PEP-8 Formatters for VS Code?
I just put your keywords in my preferred search engine and it found https://code.visualstudio.com/docs/python/editing and https://donjayamanne.github.io/pythonVSCodeDocs/docs/formatting/ as the Top 2 results. I hope this helps you. If not, you could be more specific with the problem you re having <3 More on reddit.com
๐ŸŒ r/vscode
5
1
April 19, 2021
๐ŸŒ
Visual Studio Marketplace
marketplace.visualstudio.com โ€บ items
Black Formatter - Visual Studio Marketplace
Extension for Visual Studio Code - Formatting support for Python files using the Black formatter.
๐ŸŒ
Visual Studio Marketplace
marketplace.visualstudio.com โ€บ items
Formatter extension for Visual Studio Code using autopep8
March 24, 2026 - Extension for Visual Studio Code - Formatting support for Python files using the autopep8 formatter.
๐ŸŒ
Medium
medium.com โ€บ @craakash โ€บ effortless-python-perfection-mastering-code-formatting-with-vs-code-extensions-e7035d58c4a3
Effortless Python Perfection: Mastering Code Formatting with VS Code Extensions | by Aakash Chavan Ravindranath, Ph.D | Medium
April 11, 2024 - Step 2: Installing the Python Extension for VS Code ยท Before formatting Python code, you need to install the Python extension for VS Code. This extension provides enhanced support for Python, including features such as IntelliSense, linting, ...
๐ŸŒ
Medium
medium.com โ€บ @huzaifazahoor654 โ€บ best-vs-code-extensions-for-python-developers-e64d6509e96
Best VS Code Extensions for Python Developers | by Huzaifa Zahoor | Medium
April 21, 2023 - It is a powerful extension that can help you write better and more efficient code. ... Black Formatter is a code formatter for Python that can help you write code that conforms to the PEP 8 style guide.
Find elsewhere
๐ŸŒ
Donjayamanne
donjayamanne.github.io โ€บ pythonVSCodeDocs โ€บ docs โ€บ formatting
Formatting | Python in Visual Studio Code
"python.formatting.autopep8Path": "c:/path/autopep8.exe" You can configure the format provider by changing a setting in the User or Workspace settings file as follows: ... This is generally unnecessary. As the Extension will resolve the path to the formatter based on Python executable being used or configured in python.pythonPath of settings.json.
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ languages โ€บ python
Python in Visual Studio Code
November 3, 2021 - The Python extension automatically detects Python interpreters that are installed in standard locations. It also detects conda environments as well as virtual environments in the workspace folder. See Configuring Python environments. The current environment is shown on the right side of the VS Code Status Bar: The Status Bar also indicates if no interpreter is selected: The selected environment is used for IntelliSense, auto-completions, linting, formatting, and any other language-related feature.
๐ŸŒ
GitHub
github.com โ€บ microsoft โ€บ vscode-autopep8
GitHub - microsoft/vscode-autopep8: Formatting support for python using autopep8.
A Visual Studio Code extension with support for the autopep8 formatter. The extension ships with autopep8=2.3.2. Note: The minimum supported version of autopep8 is 2.3.2. If you have any issues with formatting with autopep8, please report it ...
Starred by 33 users
Forked by 20 users
Languages ย  Python 93.2% | TypeScript 6.5% | JavaScript 0.3% | Python 93.2% | TypeScript 6.5% | JavaScript 0.3%
๐ŸŒ
GitHub
github.com โ€บ microsoft โ€บ vscode-black-formatter
GitHub - microsoft/vscode-black-formatter: Formatting support for Python using the Black formatter ยท GitHub
A Visual Studio Code extension with support for the Black formatter. The extension ships with black=26.1.0. Note: The minimum version of Black this extension supports is 26.1.0. This extension includes support for all actively supported versions of the Python language.
Starred by 191 users
Forked by 46 users
Languages ย  Python 87.3% | TypeScript 12.3% | JavaScript 0.4%
๐ŸŒ
Visual Studio Marketplace
marketplace.visualstudio.com โ€บ items
Python - Visual Studio Marketplace
March 27, 2026 - Extension for Visual Studio Code - Python language support with extension access points for IntelliSense (Pylance), Debugging (Python Debugger), linting, formatting, refactoring, unit tests, and more.
๐ŸŒ
GitHub
github.com โ€บ joslarson โ€บ black-vscode
GitHub - joslarson/black-vscode: Deprecated: VS Code extension to format Python code using Black ยท GitHub
VS Code extension to format Python code using ambv/black. Find this extension in VS Code's extension marketplace by searching for Black - Python code formatter, or to install it from the command line run the following:
Author ย  joslarson
๐ŸŒ
LinkedIn
linkedin.com โ€บ pulse โ€บ automating-python-code-formatting-visual-studio-chris-mamon
Automating Python Code Formatting in Visual Studio Code
August 24, 2023 - The Black Formatter extension for VSCode allows users to integrate Black, making code formatting straightforward. Ruff is an extremely fast Python linter, written in Rust. Linters are tools designed to analyze code for potential errors or stylistic ...
๐ŸŒ
Towards The Cloud
towardsthecloud.com โ€บ blog โ€บ best-vscode-extensions-python
10 Best VS Code Extensions for Python Developers (2026) | Towards The Cloud
March 26, 2026 - In order to enable Black as the default formatter of your Python code, you should add the following values in your vscode settings:
๐ŸŒ
Orchestra
getorchestra.io โ€บ guides โ€บ how-to-install-black-formatter-on-vs-code
How to Install Black Formatter on VS Code | Orchestra
March 27, 2026 - Learn how to install and configure Black Formatter on VS Code to streamline Python code formatting and ensure consistent code style.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ top-vs-code-extensions-for-python
Top 10 VS Code Extensions For Python [2025] - GeeksforGeeks
July 23, 2025 - This is the essential VS Code extension for Python, developed by Microsoft itself. While creating a .py file, VS Code will itself suggest installing this extension. It provides features like analyzing code for potential errors, code formatting, debugging through a debug console, testing with the unit test, pytest, and nose test frameworks.
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ python โ€บ editing
Editing Python in Visual Studio Code
November 3, 2021 - For more information about editing in Visual Studio Code, see Basic Editing and Code Navigation. In this overview, we will describe the specific editing features provided by the Python extension, including steps on how to customize these features via user and workspace settings.
๐ŸŒ
DEV Community
dev.to โ€บ adamlombard โ€บ how-to-use-the-black-python-code-formatter-in-vscode-3lo0
VSCode: Using Black to automatically format Python - DEV Community
April 4, 2024 - It can be configured to automatically format your code whenever you save a file in VSCode. ... Open your VSCode settings, by going 'Code -> Preferences -> Settings'. Search for "python formatting provider" and select "black" from the dropdown menu: