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 under the rules and on the dates stated below: files, total lines, code lines, comment lines, blank lines, and per-language totals, pinned to the exact commits listed below.

This page compares the source lines of code (SLOC) of psf/black and astral-sh/ruff using cached OctoCounts reports. Code size is not code quality: a larger count only means more source material, not a better or worse project.

As of 2026-11-16, psf/black contains 110,031 total lines (102,222 code) across 70 files, while astral-sh/ruff contains 1,298,134 total lines (661,062 code) across 3,935 files as of 2026-11-16. astral-sh/ruff has about 6.5x the counted code lines of psf/black under the same engine and counting rules. Code size is not code quality: a larger count only means more source material, not a better or worse project.

Metricpsf/blackastral-sh/ruff
Files703,935
Total lines110,0311,298,134
Code lines102,222661,062
Comment lines4,251485,034
Blank lines3,558152,038
Languages counted915

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.5% of code), Python (3.1% of code), JSON (2.6% of code). Python, JSON, YAML appear in both top language lists; Vim Script, TOML 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 main (commit 8f4a058eeb2c) on 2026-11-16; astral-sh/ruff was counted at ref main (commit d3e454ea7c0a) on 2026-11-16. See the counting methodology for ignored directories and analysis options.

Both reports use the same engine and effective counting rules. Repository declarations, when enabled, are specific to each repository. psf/black: tokei-15.0.0, policy directories-v1; docs excluded, tests excluded, generated excluded. Excluded directory names: .cache, .generated, .git, .next, __tests__, build, dist, doc, docs, documentation, fixtures, gen, generated, node_modules, target, test, tests, vendor. Ignored languages: none. Repository declarations: off. Exclusions are rule-based; they do not prove that every test, document or generated file was removed. astral-sh/ruff: tokei-15.0.0, policy directories-v1; docs excluded, tests excluded, generated excluded. Excluded directory names: .cache, .generated, .git, .next, __tests__, build, dist, doc, docs, documentation, fixtures, gen, generated, node_modules, target, test, tests, vendor. Ignored languages: none. Repository declarations: off. Exclusions are rule-based; they do not prove that every test, document or generated file was removed.

About this comparison

Background observations recorded on 2026-09-16; language descriptions here are historical context, not claims about the current filtered shares. Use this page's measured language breakdown for current counts. Repository layout before counting filters: psf/black is the Black repository: the opinionated Python formatter, its test corpus, and documentation. astral-sh/ruff is the Ruff repository: a Python linter and formatter written in Rust, maintained as a workspace of crates. Both repositories are small relative to the frameworks on this site, and their measurements were taken on the dates shown above; the comparison is a single-purpose formatter against a multi-tool repository.

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 · astral-sh/ruff repository (Rust workspace). Statements verified 2026-09-16.

Evidence and next steps:

Saved reports remain subject to cache cleanup and replacement. Export their JSON for durable citation; live report URLs can change.

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?

As of 2026-11-16, psf/black contains 110,031 total lines (102,222 code) across 70 files, while astral-sh/ruff contains 1,298,134 total lines (661,062 code) across 3,935 files as of 2026-11-16. astral-sh/ruff has about 6.5x the counted code lines of psf/black under the same engine and counting rules. Code size is not code quality: a larger count only means more source material, not a better or worse project.

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 main (commit 8f4a058eeb2c) on 2026-11-16; astral-sh/ruff was counted at ref main (commit d3e454ea7c0a) on 2026-11-16. 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.