# 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 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, fastapi/fastapi contains 35,047 total lines (29,612 code) across 544 files, while pallets/flask contains 34,156 total lines (25,636 code) across 210 files as of 2026-09-20. fastapi/fastapi is about 1.2x the size of pallets/flask by code lines. Code size is not code quality: a larger count only means more source material, not a better or worse project.

| Metric | [fastapi/fastapi](https://octocounts.com/github/fastapi/fastapi) | [pallets/flask](https://octocounts.com/github/pallets/flask) |
| --- | ---: | ---: |
| Files | 544 | 210 |
| Total lines | 35,047 | 34,156 |
| Code lines | 29,612 | 25,636 |
| Comment lines | 1,073 | 985 |
| Blank lines | 4,362 | 7,535 |
| Languages counted | 7 | 12 |

Top languages in fastapi/fastapi: Python (98.6% of code), TOML (1.1% of code), JavaScript (0.1% of code). Top languages in pallets/flask: Python (54.6% of code), ReStructuredText (42.2% of code), TOML (1.3% 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 50113da16fec53b66b80d75e80a89296de4fa5a5 (commit 50113da16fec) on 2026-09-16; pallets/flask was counted at ref main (commit d73fa1cdcbd8) on 2026-09-20. See the [counting methodology](https://octocounts.com/docs/methodology) for ignored directories and analysis options.
## About this comparison

fastapi/fastapi counts the FastAPI repository: the web framework's Python source, documentation, and examples, built on top of the Starlette toolkit and Pydantic. pallets/flask counts the Flask repository: a deliberately minimal Python web framework with its documentation and tests. Both counts 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](https://github.com/fastapi/fastapi) · [pallets/flask repository](https://github.com/pallets/flask). Statements verified 2026-09-16.

Evidence and next steps:

- [fastapi/fastapi SLOC report](https://octocounts.com/github/fastapi/fastapi)
- [pallets/flask SLOC report](https://octocounts.com/github/pallets/flask)
- [Compare fastapi/fastapi and pallets/flask interactively](https://octocounts.com/compare?left=https%3A%2F%2Fgithub.com%2Ffastapi%2Ffastapi&right=https%3A%2F%2Fgithub.com%2Fpallets%2Fflask)

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?

fastapi/fastapi has more code: 29,612 code lines versus 25,636 for pallets/flask, about 1.2x as much, based on cached OctoCounts reports as of 2026-09-20.

### 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 50113da16fec53b66b80d75e80a89296de4fa5a5 (commit 50113da16fec) on 2026-09-16; pallets/flask was counted at ref main (commit d73fa1cdcbd8) on 2026-09-20. 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)
