FastAPI vs Flask: source lines of code compared

The FastAPI vs Flask comparison on OctoCounts shows side-by-side source line counts for fastapi/fastapi and pallets/flask, 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 fastapi/fastapi and pallets/flask 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, fastapi/fastapi contains 36,766 total lines (31,118 code) across 571 files, while pallets/flask contains 12,824 total lines (10,225 code) across 61 files as of 2026-10-31. fastapi/fastapi has about 3.0x the counted code lines of pallets/flask 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.

Metricfastapi/fastapipallets/flask
Files57161
Total lines36,76612,824
Code lines31,11810,225
Comment lines1,110793
Blank lines4,5381,806
Languages counted78

Top languages in fastapi/fastapi: Python (98.6% of code), TOML (1.2% of code), JavaScript (0.1% of code). Top languages in pallets/flask: Python (78.8% of code), ReStructuredText (14.4% of code), TOML (3.2% of code). Python, TOML, HTML appear in both top language lists; JavaScript, Shell appear only in fastapi/fastapi's top languages; ReStructuredText, CSS appear only in pallets/flask's top languages.

Methodology: both counts come from cached OctoCounts reports generated with tokei. fastapi/fastapi was counted at ref master (commit a1b3be01aadc) on 2026-11-16; pallets/flask was counted at ref main (commit 49943b5a9441) on 2026-10-31. 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. fastapi/fastapi: 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. pallets/flask: 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: fastapi/fastapi is the FastAPI repository: the web framework's Python source, documentation, and examples, built on top of the Starlette toolkit and Pydantic. pallets/flask is the Flask repository: a deliberately minimal Python web framework with its documentation and tests. Both repositories are framework source trees, taken on the dates shown in the methodology line.

Both repositories are Python codebases, so the per-language tables are dominated by Python on both sides; the more interesting reading on this page is the totals relative to each project's stated scope.

FastAPI builds on external libraries (Starlette for the HTTP layer, Pydantic for data validation) that are not part of its repository, while Flask keeps more of its core in-tree — so neither count includes everything each framework relies on at runtime.

FastAPI's dependence on Starlette and Pydantic means its repository total understates the code involved in serving a FastAPI app; comparing the two totals is not comparing like-for-like stacks.

Sources: fastapi/fastapi repository · pallets/flask repository. 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, fastapi/fastapi or pallets/flask?

As of 2026-11-16, fastapi/fastapi contains 36,766 total lines (31,118 code) across 571 files, while pallets/flask contains 12,824 total lines (10,225 code) across 61 files as of 2026-10-31. fastapi/fastapi has about 3.0x the counted code lines of pallets/flask 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 fastapi/fastapi, pallets/flask, or any repository.

How is this comparison calculated?

Methodology: both counts come from cached OctoCounts reports generated with tokei. fastapi/fastapi was counted at ref master (commit a1b3be01aadc) on 2026-11-16; pallets/flask was counted at ref main (commit 49943b5a9441) on 2026-10-31. 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.