Freedom251 › Code Formatting Tools
Black

What Black is
Black is a free, MIT-licensed formatter for Python code that applies a consistent style based on PEP 8. It reformats whole files in place with a default line length of 88 characters, while offering few style choices. After formatting, it checks whether the abstract syntax tree remains effectively equivalent and raises an error if that check fails. Black installs with pip and requires Python 3.10 or newer. It is primarily a command-line tool and does not provide a Python interface. The documentation lists integrations for editors and IDEs such as PyCharm, Vim, Neovim, Visual Studio Code, Sublime Text, and others, plus GitHub Actions and doctest formatting. Notebook formatting is available with the jupyter extra, but some cells containing certain magics or invalid syntax are skipped. Black also includes blackd, an HTTP server that binds to localhost by default. Stable releases preserve formatting within the same calendar year when the options match. Indentation style cannot be configured.
Who it suits
It suits Python developers who want a consistent formatter in command-line, editor, or GitHub Actions workflows. Notebook users can add the jupyter extra, while accounting for cells Black skips.
What it does well
- Free and MIT-licensed.
- Formats entire Python files in place.
- Checks abstract syntax tree equivalence.
- Integrates with editors and GitHub Actions.
- Supports notebook formatting with the jupyter extra.
What to know first
- Requires Python 3.10 or newer.
- Does not provide a Python interface.
- Indentation style cannot be configured.
- Some notebook cells are skipped.
Limits
Black does not offer configurable indentation style or a Python library interface. Notebook formatting skips cells containing certain magics, transformed magic code, non-Python or multiline magics, or invalid syntax.
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| Black | MIT-licensed Python code formatter | Free |
As black.readthedocs.io lists them, read 29 Sept 2026. The maker's own page has the final word.
Getting started
- Open https://black.readthedocs.io/.
- Install Black with pip in a Python 3.10-or-newer environment.
- Run Black as a command-line formatter on Python files.
- For notebook formatting, install Black with the jupyter extra.
- Use a documented editor integration or GitHub Actions integration if it fits your workflow.
Black is a Python formatter for developers and teams who want a shared style enforced across files, editors, and automation. It favors predictable formatting over fine-grained control: accept its rules and it can simplify routine style decisions; need custom indentation or a Python library interface and it is a poor fit.
Overview
Black follows PEP 8 and reformats complete files in place, using an 88-character default line length. Its limited style choices are a practical way to reduce formatting debates across a project, but they also mean teams cannot use it to preserve every existing convention. In particular, indentation style cannot be configured.
Black aims to keep diffs small, which can make formatting changes easier to review. It also checks that the reformatted code has an effectively equivalent abstract syntax tree and raises an error if that check fails. Stable releases are intended to produce unchanged formatting across releases in the same calendar year when the same options are used, helping limit style churn within that period.
Key features
- Whole-file formatting: Black applies its style to full files rather than only changed lines. This suits projects seeking uniform output, though it may create a broader formatting change than a changed-lines workflow.
- Editor and automation integrations: Documented integrations cover editors including Emacs, PyCharm and IntelliJ IDEA, Vim, Neovim, Visual Studio Code, and Sublime Text, as well as GitHub Actions, source version control, and doctest formatting. This makes Black usable in both local editing and automated project workflows.
- Notebook formatting: Installing Black with the jupyter extra enables Jupyter Notebook formatting. It skips cells with automagics, non-Python or multiline magics, transformed magic code, or invalid syntax, so notebooks that rely on those cells may not be fully formatted.
- Local service and containers: The included blackd HTTP server binds to localhost by default, and official Docker images are available with release and prerelease tags. These options support local service or container-based workflows without changing Black's command-line orientation.
Pricing
Black is free: its plan costs nothing and is an MIT-licensed open-source Python formatter. There is no paid tier or free trial to weigh against it; the trade-off is functional rather than commercial. Black requires Python 3.10 or newer to run, and it does not provide a Python interface, so teams wanting a library API must choose another approach.
Platforms
Black supports Windows, macOS, and Linux, and can be installed with pip. Its local HTTP server and Docker images extend deployment options, while editor integrations connect it to common development environments. Black promises support for Python versions that have not reached end of life, both for running the formatter and formatting code.
Who it's for
Black is best for Python projects that value a consistent, low-debate style and want formatting integrated into editors or CI. It is less suitable for teams that need configurable indentation, a Python library API, or notebook formatting that handles every kind of magic cell. Its MIT license and zero price also make it straightforward to adopt across projects without a subscription decision.
Pros and cons
- Pro: A consistent style and whole-file formatting reduce project-by-project formatting choices.
- Pro: The abstract-syntax-tree equivalence check can catch a formatting result that is not effectively equivalent.
- Pro: Editor, GitHub Actions, version-control, and doctest integrations support use beyond a standalone command.
- Con: No indentation-style setting means teams cannot adapt Black to a different indentation convention.
- Con: The command-line focus and lack of a Python interface limit use as an imported formatting library.
- Con: Notebook cells using certain magics or invalid syntax are skipped, leaving some notebook content outside its formatting pass.
Alternatives
For a directory of code formatting tools, start with the broader category. Choose Prettier instead if you need a free formatter with API, extension, web, and desktop-platform availability; its listed plan is free, with enterprise support and maintenance offered through Tidelift Subscription. Ruff is another free option for readers comparing tools in the Python ecosystem; its maker describes its tools as open source and permissively licensed.
Accessibility Test Framework for Android is a free alternative for readers looking at an Android accessibility test framework rather than a Python formatter. rustfmt is a free formatter option for Rust projects. Biome is a free open-source toolchain for web projects. CSharpier offers free opinionated formatting for C# and XML and installs as a .NET tool. dprint is a free MIT-licensed CLI with self-managed installation. gofmt is a free command-line formatter included with Go.
Verdict
Choose Black if your Python project wants consistent formatting enforced across whole files, with editor and automation integrations and a syntax-equivalence check. Its clearest reason to look elsewhere is the same design choice that makes it dependable: Black does not bend to custom indentation, and it offers no Python library API.
Verdict
Black is a focused Python formatter with editor and automation integrations, plus a check that reformatted code remains effectively equivalent. Its command-line orientation and fixed indentation style may not suit every workflow.
Questions
Does Black cost anything?
No. Black is listed as free and is licensed under the MIT License.
Which language does Black format?
Black supports Python.
Which operating systems does it support?
The listed platforms are Windows, macOS, and Linux.
Does Black have a Python library API?
No. Black is primarily a command-line tool and does not provide a Python interface.
Can Black format Jupyter Notebooks?
Yes. Notebook formatting is available by installing Black with the jupyter extra, though some cells are skipped.
What Python version does it require?
Black requires Python 3.10 or newer to run.
Facts from Black's own pages
- API limit
- Black is fundamentally a command-line tool and does not currently provide a Python interface. · black.readthedocs.io, 28 Sept 2026
- CI integration
- Black provides a GitHub Actions integration that supports GitHub-hosted runner operating systems. · black.readthedocs.io, 28 Sept 2026
- Code review
- Black says it can make code review faster by producing the smallest diffs possible. · black.readthedocs.io, 29 Sept 2026
- Command line tool
- Black is fundamentally a command line tool and the documentation says it does not yet provide a Python interface. · black.readthedocs.io, 29 Sept 2026
- Configuration limit
- Black provides no option to configure indentation style and says requests for that option will not be considered. · black.readthedocs.io, 29 Sept 2026
- Consistent style
- Black limits style options and aims to make code look consistent across projects. · black.readthedocs.io, 28 Sept 2026
- Docker
- Official Black Docker images are available, with tags for releases and prereleases. · black.readthedocs.io, 28 Sept 2026
- Editor integrations
- The documentation describes integrations for editors including PyCharm, Vim, Neovim, Visual Studio Code, and Sublime Text. · black.readthedocs.io, 28 Sept 2026
- Editor support
- Documented editor integrations include Emacs, PyCharm and IntelliJ IDEA, Vim, Neovim, Visual Studio Code, SublimeText, and others. · black.readthedocs.io, 29 Sept 2026
- Formatting
- Black reformats whole files in place and uses a default line length of 88 characters. · black.readthedocs.io, 28 Sept 2026
- Installation
- Black installs with pip or pipx and requires Python 3.10 or later to run. · black.readthedocs.io, 29 Sept 2026
- Integrations
- The documentation lists editor and IDE, GitHub Actions, source version control, and doctest formatting integrations. · black.readthedocs.io, 29 Sept 2026
- License
- Black is licensed under the MIT license. · black.readthedocs.io, 29 Sept 2026
- Local server
- Black includes blackd, an HTTP server that binds to localhost by default. · black.readthedocs.io, 28 Sept 2026
- Notebook limits
- Black skips notebook cells containing automagics, non-Python or multiline magics, transformed magic code, or invalid syntax. · black.readthedocs.io, 29 Sept 2026
- Notebook support
- Jupyter Notebook formatting is available with the black[jupyter] installation extra. · black.readthedocs.io, 29 Sept 2026
- Purpose
- Black is an opinionated formatter for Python code that follows PEP 8. · black.readthedocs.io, 28 Sept 2026
- Python compatibility
- Black promises support for Python versions that have not reached end of life, for both running Black and formatting code. · black.readthedocs.io, 29 Sept 2026
- Safety check
- Black checks that reformatted code has a valid AST effectively equivalent to the original and raises an error without changing the file if issues are found. · black.readthedocs.io, 29 Sept 2026
- Style stability
- For stable releases, code formatted with a release remains unchanged under other releases in the same calendar year when using the same options. · black.readthedocs.io, 28 Sept 2026
- What it does
- Black is an opinionated code formatter that formats Python code with consistent style. · black.readthedocs.io, 29 Sept 2026
Where Black stands on Freedom251
- Code Formatting Tools#4 of 34