Black reformats Python source in place with consistent PEP 8-oriented style and limited configuration. It runs from the command line, supports Jupyter notebooks optionally, and reads defaults from pyproject.toml.
Overview
Black is a deterministic formatter for Python that replaces hand-tuned layout with a single shared style across projects. It reformats entire files at once, aims for minimal diffs in version control, and validates that output parses to an equivalent abstract syntax tree unless a fast mode skips that check.
Configuration stays intentionally small: teams can set include and exclude globs via pyproject.toml while most users rely on defaults. The tool supports editor integrations, pre-commit hooks, GitHub Actions, a blackd formatting server, Docker images, and standalone PyInstaller binaries for machines without a local Python install.
Stability policy documents how the style may evolve, with separate notes for current, future, and preview formatting rules. Optional Jupyter support formats notebook cells, and compatibility guides describe settings that align Black with other linters and formatters.
Key features
- In-place whole-file formatting
- PEP 8 oriented fixed style
- pyproject.toml configuration
- AST equivalence safety check
- Jupyter notebook formatting option
- Editor and CI integrations
- Optional blackd format server
- Standalone executable builds
Use cases
- Standardizing Python style in repos
- Shrinking formatting debates in review
- Pre-commit formatting enforcement
- Consistent style across many projects
- Automated notebook cleanup