Prettier does not support Python formatting. It is designed for languages like JavaScript, TypeScript, CSS, HTML, JSON, and others, but not Python.

For Python code formatting, use dedicated tools instead:

  • Black: The most popular and widely adopted Python formatter. It enforces a consistent, opinionated style with minimal configuration. Install via pip install black. It supports Jupyter notebooks with pip install "black[jupyter]".

  • Ruff: A modern, ultra-fast replacement for flake8, pylint, and black. It combines linting and formatting, supports Jupyter notebooks, and is significantly faster than older tools. Install via pip install ruff and configure in VS Code using the charliermarsh.ruff extension.

  • autopep8 or yapf: Alternative formatters that follow PEP 8 guidelines, offering more configurability than Black.

Setting Up Formatting in VS Code:

To avoid conflicts when using Prettier for web languages and Python formatters:

  1. Disable Prettier as the default formatter for Python in settings.json:

    "[python]": {
      "editor.defaultFormatter": null
    }
  2. Set your preferred Python formatter:

    • For Black:

      "python.formatting.provider": "black",
      "python.formatting.blackArgs": ["--line-length=120"]
    • For Ruff (recommended):

      "editor.defaultFormatter": "charliermarsh.ruff",
      "editor.formatOnSave": true,
      "editor.codeActionsOnSave": {
        "source.organizeImports": "explicit"
      }

Tip: Ruff is the fastest and most modern choice for Python formatting and linting in 2026. It’s recommended over older tools like Black for new projects.

There's probably no such thing as "perfect", but there are programs like " black " that ensure the code is formatted "correctly". Answer from JamzTyson on reddit.com
Discussions

Making a prettier GUI on Python program
I’m making this simple health app in Python. I’m using PyQt6 for the GUI. It all works, the data persistence is with SQLite 3. It acts as a CRUD application, but also can create an output file to show your doctor, and can rate whether or not your symptom is getting worse based on whether ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
August 16, 2022
automatic prettier for python code? (as in javascript) - Emacs Stack Exchange
https://github.com/prettier/prettier-emacs does formatting for javascript wonder if there's an equivalent for python code? More on emacs.stackexchange.com
🌐 emacs.stackexchange.com
May 25, 2020
Is there something like prettier for python? : learnpython
I just want to reformat everything so it's perfect. Is there anything like that in Python? What's the best? More on old.reddit.com
🌐 r/learnpython
Which code formatter do you use?
Black. We don't care that it may look bad. We don't want to argue about formatting. We know it isn't configurable, that's the point. We don't want to deal with everyone's configuration preferences. More on reddit.com
🌐 r/Python
144
68
December 21, 2022
🌐
Visual Studio Code
code.visualstudio.com › docs › python › formatting
Formatting Python in VS Code
November 3, 2021 - Note: If you don't find your preferred formatter listed above, you can add support via an extension. The Python Extension Template makes it easy to integrate new Python tools into VS Code.
🌐
DEV Community
dev.to › eegli › quick-guide-to-python-formatting-in-vs-code-2040
Quick Guide to Python Formatting in VS Code (2025) - DEV Community
February 1, 2025 - Through your article I put my editor's default editor as prettier and for python I disable it and use black as the editor. I did all this in the JSON based settings . Great article.
🌐
Code Beautify
codebeautify.org › python-formatter-beautifier
Python Formatter and Beautifier
Best Python Formatter will help to format, beautify, minify, compact Python code, string, text. Format, Save, Share
Find elsewhere
🌐
Python
docs.python.org › 3 › library › pprint.html
pprint — Data pretty printer
The pprint module provides a capability to “pretty-print” arbitrary Python data structures in a form which can be used as input to the interpreter. If the formatted structures include objects which are not fundamental Python types, the ...
🌐
JetBrains
jetbrains.com › help › pycharm › prettier.html
Prettier | PyCharm Documentation
November 24, 2025 - Prettier is a tool to format files in various languages, like TypeScript, JavaScript, CSS, HTML, JSON, and others. With PyCharm, you can format selected code fragments as well as entire files or directories using the Reformat with Prettier action.
🌐
GitHub
github.com › psf › black
GitHub - psf/black: The uncompromising Python code formatter · GitHub
Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting.
Starred by 41.4K users
Forked by 2.7K users
Languages   Python
🌐
GitHub
github.com › prettier › plugin-python
GitHub - prettier/plugin-python: Prettier Python Plugin · GitHub
October 1, 2019 - Prettier Python Plugin. Contribute to prettier/plugin-python development by creating an account on GitHub.
Starred by 520 users
Forked by 38 users
Languages   JavaScript 72.2% | Python 27.8%
🌐
Pyrfecter
pyrfecter.com › format-python-code
Format Python code online · Pyrfecter
June 26, 2025 - If you have Python code you want to format online, look no further. Pyrfecter is an easy and secure way to format, lint, and improve your Python code all from inside your browser. Even if your code is well written Pyrfecter can help.
🌐
freeCodeCamp
forum.freecodecamp.org › code feedback
Making a prettier GUI on Python program - Code Feedback - The freeCodeCamp Forum
I’m making this simple health app in Python. I’m using PyQt6 for the GUI. It all works, the data persistence is with SQLite 3. It acts as a CRUD application, but also can create an output file to show your doctor, and can rate whether or not your symptom is getting worse based on whether ...
Published   August 16, 2022
🌐
Prettier
prettier.io › docs › plugins
Plugins · Prettier
Check out prettier-python's printer for some examples of what is possible.
🌐
DEV Community
dev.to › amnish04 › static-analysis-tooling-11e3
Linting and Formatting a Python Project - DEV Community
November 15, 2023 - The following interview of my open ... of prettier, does a great job at highlighting the importance of such formatters, and how blessed we should feel to have them at our disposal. ... There are various types of such tools focussing on different areas like code formatters, linters, security scanners and many more. But I'll only be focusing on the first two in this post. The first thing I had to do was decide what code formatter and linter I would use in my python ...
🌐
npm
npmjs.com › package › prettier
prettier - npm
January 21, 2026 - Prettier is an opinionated code formatter. Latest version: 3.8.1, last published: 2 months ago. Start using prettier in your project by running `npm i prettier`. There are 20167 other projects in the npm registry using prettier.
      » npm install prettier
    
Published   Jan 21, 2026
Version   3.8.1
Author   James Long
🌐
Astral
docs.astral.sh › ruff › formatter
The Ruff Formatter | Ruff
As such, the formatter is designed as a drop-in replacement for Black, but with an excessive focus on performance and direct integration with Ruff. Given Black's popularity within the Python ecosystem, targeting Black compatibility ensures that formatter adoption is minimally disruptive for the vast majority of projects.
🌐
Black
black.readthedocs.io
Black 26.3.0 documentation
Black has a comprehensive test ... changes to formatting in the future. Stylistic changes will mostly be responses to bug reports and support for new Python syntax....