Instead of Black: Ruff
Use ruff format instead of Black. It is designed as a drop-in replacement and produces the same output for 99.9% of lines on Black-formatted projects such as Django. It is much faster and shares one tool and one config with your linter.
Both are for formatting Python code automatically.
Why Ruff is better
- On large Black-formatted projects like Django and Zulip, Astral reports that 99.9% of lines come out identical, so switching causes almost no diff.
- Astral reports Ruff as 10 to 100 times faster than formatters like Black, which makes format-on-save instant on big files.
- The same ruff binary lints, sorts imports and formats, configured in one [tool.ruff] section, instead of Black plus isort plus a linter.
When to keep Black
Keep Black if your team treats Black's exact output as a contract, for example a large monorepo where even a small diff is costly. Also keep it if you rely on Black's stability policy for its yearly style.
Switching
Swap the black command for ruff format in your pre-commit hook and CI job, and copy line-length and target-version into the [tool.ruff] section of pyproject.toml. The first run usually produces a small diff in edge cases, which you commit once. Ruff's FAQ lists the known places where its output differs from Black's.
Watch out
On code that was never Black-formatted, Ruff makes some different choices than Black. Ruff is MIT-licensed, so a fork stays possible whatever OpenAI, which bought Astral in March 2026, decides.
More newer, better linters, formatters and type checkers
Sources
- Ruff formatter documentation
- Ruff FAQ
- Black documentation
- Real Python: Ruff
- Ruff documentation
- Simon Willison: Thoughts on OpenAI acquiring Astral
Judged on 2026-11-06. See every linters, formatters and type checkers, or all 66 replacements.