# Black vs Ruff: source lines of code compared

The Black vs Ruff comparison on OctoCounts shows side-by-side source line counts for psf/black and astral-sh/ruff, counted with the same engine and analysis options on the dates shown in the methodology line: files, total lines, code lines, comment lines, blank lines, and per-language totals, pinned to the exact commits listed below.

As of 2026-09-16, psf/black contains 108,302 total lines (101,107 code) across 73 files, while astral-sh/ruff contains 1,155,501 total lines (619,747 code) across 3,796 files as of 2026-09-15. astral-sh/ruff is about 6.1x the size of psf/black by code lines. Code size is not code quality: a larger count only means more source material, not a better or worse project.

| Metric | [psf/black](https://octocounts.com/github/psf/black) | [astral-sh/ruff](https://octocounts.com/github/astral-sh/ruff) |
| --- | ---: | ---: |
| Files | 73 | 3,796 |
| Total lines | 108,302 | 1,155,501 |
| Code lines | 101,107 | 619,747 |
| Comment lines | 3,827 | 401,317 |
| Blank lines | 3,368 | 134,437 |
| Languages counted | 9 | 12 |

Top languages in psf/black: Python (99.1% of code), Vim Script (0.4% of code), TOML (0.2% of code). Top languages in astral-sh/ruff: Rust (91.6% of code), Python (2.9% of code), JSON (2.7% of code). Python, TOML, JSON appear in both top language lists; Vim Script, YAML appear only in psf/black's top languages; Rust, TSX appear only in astral-sh/ruff's top languages.

Methodology: both counts come from cached OctoCounts reports generated with tokei. psf/black was counted at ref acd6198877ced2d8126b9b3958bb17f4a65ef0d1 (commit acd6198877ce) on 2026-09-16; astral-sh/ruff was counted at ref 1eab8c883aa32324a2710c1a277bf614b86cfba3 (commit 1eab8c883aa3) on 2026-09-15. See the [counting methodology](https://octocounts.com/docs/methodology) for ignored directories and analysis options.
## About this comparison

psf/black counts the Black repository: the opinionated Python formatter, its test corpus, and documentation. astral-sh/ruff counts the Ruff repository: a Python linter and formatter written in Rust, maintained as a workspace of crates. Both counts are small relative to the frameworks on this site, and both were taken on the dates shown above; the comparison is a single-purpose formatter against a multi-tool repository.

The per-language tables tell the implementation story directly: Black is counted as a Python project, while Ruff's counted code is predominantly Rust with Python fixtures and documentation — each project's chosen language for the tool itself.

Ruff's repository covers linting and formatting in one workspace, while Black's repository covers formatting alone, so the totals describe tools of different scope rather than two implementations of exactly the same job.

_These counts cannot settle speed or compatibility questions — Ruff's formatter targets Black-compatible output, and performance depends on the installed versions and the rules configured. The numbers describe source-tree size only._

Sources: [psf/black repository](https://github.com/psf/black) · [astral-sh/ruff repository (Rust workspace)](https://github.com/astral-sh/ruff). Statements verified 2026-09-16.

Evidence and next steps:

- [psf/black SLOC report](https://octocounts.com/github/psf/black)
- [astral-sh/ruff SLOC report](https://octocounts.com/github/astral-sh/ruff)
- [Compare psf/black and astral-sh/ruff interactively](https://octocounts.com/compare?left=https%3A%2F%2Fgithub.com%2Fpsf%2Fblack&right=https%3A%2F%2Fgithub.com%2Fastral-sh%2Fruff)

Note: code size is not code quality. OctoCounts only reports reproducible line counts and makes no claim that either project is better.

## Compare FAQ

### Which has more lines of code, psf/black or astral-sh/ruff?

astral-sh/ruff has more code: 619,747 code lines versus 101,107 for psf/black, about 6.1x as much, based on cached OctoCounts reports as of 2026-09-16.

### Does more source lines of code mean more complexity?

Not necessarily. SLOC measures size, not complexity, quality, or maintainability. A larger codebase can mean more features, more generated or vendored code, more verbose language idioms, or more tests — none of which imply the code is harder to work with. Use SLOC to gauge the scale of what you'd be reading or maintaining, not as a quality signal for psf/black, astral-sh/ruff, or any repository.

### How is this comparison calculated?

Methodology: both counts come from cached OctoCounts reports generated with tokei. psf/black was counted at ref acd6198877ced2d8126b9b3958bb17f4a65ef0d1 (commit acd6198877ce) on 2026-09-16; astral-sh/ruff was counted at ref 1eab8c883aa32324a2710c1a277bf614b86cfba3 (commit 1eab8c883aa3) on 2026-09-15. See the counting methodology for ignored directories and analysis options.

### Can I compare a different branch, tag, or commit?

Yes. This page shows the default branch for each repository. Use the interactive comparison tool to pick any public GitHub repository, branch, tag, or commit SHA for both sides and get a fresh side-by-side report.

## Related OctoCounts pages

- [Interactive repository comparison](https://octocounts.com/compare)
- [Recently analyzed repositories](https://octocounts.com/recent)
- [Popular SLOC reports](https://octocounts.com/popular)
- [Trending GitHub repositories](https://octocounts.com/trending)
- [Hall of Monoliths](https://octocounts.com/hall-of-monoliths)
- [Original research: how filtering changes SLOC counts](https://octocounts.com/research)
- [GitHub SLOC counter guide](https://octocounts.com/docs/github-sloc-counter)
- [Counting methodology](https://octocounts.com/docs/methodology)
- [SLOC and code metrics glossary](https://octocounts.com/docs/glossary)
- [OctoCounts API docs](https://octocounts.com/docs/api)
