
Black
A Python code formatter that rewrites your files to one consistent style with little configuration.
- Stars
- 42.1k
- Forks
- 3k
- Licence
- MIT
- Language
- Python
- Last update
- 4 days ago
- Type
- Dev tool
What it is
Black is a command-line tool that automatically rewrites Python code into a consistent layout, so you stop spending time on spacing, line breaks, and quote style. It is opinionated and has few settings by design, so teams and projects end up looking alike. People use it to keep code reviews focused on logic rather than formatting.
- Format a single Python file or an entire directory with one command
- Format Jupyter Notebooks after installing the jupyter extra
- Configure include and exclude patterns for a project through pyproject.toml
- Run Black automatically before each commit using pre-commit
Great for
- Python developers who want formatting handled automatically
- Teams that want every project member's code to look the same
- Projects that already use pre-commit hooks or CI checks
- People who prefer not to debate style rules
Not ideal for
- Anyone who wants fine-grained control over formatting choices, since the README says style options are deliberately limited
- Projects that need to run on Python versions older than 3.10, since the README says Black requires Python 3.10+ to run
How to get it
- 1
Install with a package manager
You'll need: Python 3.10+
Install Black with pip
pip install black - 2
Run it
- Install Black with pip install black
- Run black on a file or folder, for example: black {source_file_or_directory}
- Review the changes it made, then commit them
- 3
Get the most out of it
- Add a [tool.black] section to pyproject.toml to set include and exclude patterns for your project
- Install the jupyter extra with pip install "black[jupyter]" to format notebooks
- Use the documentation's configuration guide to adjust defaults where needed
Downloads
Strengths
- The README describes it as producing the smallest diffs possible, which makes code review easier
- Few configuration options are needed, and the README says the defaults are intended to work for most projects
- Documented stability policy means large style changes are not expected going forward
Trade-offs
- Its opinionated style means you cannot tune many formatting details
- The README notes it reformats files in place, so you should use version control before running it on existing code
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| black (this) | 42.1k | Dev tool | beginner | 4 days ago | Python developers who want formatting handled automatically |
| prettier | 52.4k | Dev tool | beginner | 4 days ago | Teams that want one shared code style without writing their own rules |
| tools | 23.3k | Dev tool | intermediate | 3.2 years ago | Developers who want one tool for formatting and linting JavaScript or TypeScript |
| gitingest | 16.1k | Dev tool | beginner | 4 days ago | Developers who want to give an AI assistant context about a codebase |
| CodeEdit | 23.1k | App | beginner | 19 days ago | Developers on a Mac who work on non-Apple projects and want a native macOS editor |
| gitdiagram | 18.7k | App | intermediate | 7 days ago | Developers getting oriented in an unfamiliar codebase |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.