Backend Frameworksintermediate

FastAPI vs Flask

FastAPI vs Flask compared for 2026: FastAPI 0.165 (ASGI on Starlette 1.10, Pydantic 2.14 validation, automatic OpenAPI 3.1 docs, async-first, MIT) vs Flask 3.1.3 (WSGI on Werkzeug, minimal core plus extensions, Jinja templates, BSD-3-Clause). Includes throughput, blocking-I/O and validation results from runs we did on the same machine, deployment with Uvicorn and Gunicorn, versioning risk and a clear pick.

Quick Answer

FastAPI and Flask are the two most popular Python microframeworks. FastAPI 0.165.0 (18 November 2026, MIT, Python 3.11+) is an ASGI framework built on Starlette and Pydantic: you declare request data with type hints and get validation, 422 error responses, serialisation and an OpenAPI 3.1 schema with Swagger UI for free. Flask 3.1.3 (18 February 2026, BSD-3-Clause, Python 3.9+) is a small WSGI framework on Werkzeug and Jinja that leaves validation, docs and databases to extensions you choose. In our single-core run, FastAPI on Uvicorn served about 6,000-6,600 JSON requests/s, Flask on one Gunicorn sync worker about 1,200-1,700 and with 8 threads about 2,900-3,200; with a 100 ms I/O wait, async FastAPI handled 487 req/s against 78 for threaded Flask. Pick FastAPI for JSON APIs, typed request contracts and I/O-heavy or async services; pick Flask for server-rendered sites, extension-driven apps, existing Flask codebases and teams that want a stable 3.x API.

Last updated November 21, 2026. Covers FastAPI 0.165.0 (18 November 2026) with Starlette 1.10.0, Pydantic 2.14.4 and Uvicorn 0.54.0, and Flask 3.1.3 (18 February 2026) with Werkzeug 3.1.9 and Gunicorn 27.0.1; release notes and docs read on 21 November 2026, plus same-machine runs we did that day.

Feature comparison of FastAPI vs Flask
FeatureFastAPIFlask
Licence & Maintainer
MIT; created by Sebastián Ramírez (tiangolo); fastapi/fastapi ~105k GitHub stars
BSD-3-Clause; Pallets project; pallets/flask ~75.3k GitHub stars
Latest Release (Nov 2026)
0.165.0 on 18 Nov 2026 (configurable form parsing limits); new releases most weeks
3.1.3 on 18 Feb 2026 (session security fix GHSA-68rp-wp8r-4726); 3.1.0 on 13 Nov 2024
Python Versions
Python 3.11+ since 0.162.6 (13 Nov 2026)
Python 3.9+
Server Interface
ASGI
WSGI (ASGI only via an adapter such as asgiref WsgiToAsgi)
Built On
Starlette 1.10 (web layer) and Pydantic 2.14 (data); Uvicorn 0.54 as default server
Werkzeug 3.1 (HTTP/WSGI), Jinja (templates), Click (CLI), ItsDangerous, Blinker
Request Validation
Automatic from type hints and Pydantic models for path, query, header, cookie, form and body; 422 with per-field errors
None built in; extensions or Pydantic/marshmallow by hand
API Documentation
Automatic OpenAPI 3.1 schema; Swagger UI at /docs and ReDoc built in
None built in; via extensions
Async Support
Native async def endpoints; def endpoints run in a thread pool; WebSockets
async def views run in an event loop on a thread per request; Quart recommended for async-heavy apps
Dependency Injection
Depends() with sub-dependencies, yield cleanup and max_concurrency (0.163.0+)
None; app and request context globals (g, current_app) and extensions
HTML Templates
No template layer of its own; add Jinja yourself (not the focus)
Jinja built in
Extensions & Batteries
Starlette middleware and the wider Pydantic/ASGI ecosystem; no official extension registry
Large community extension ecosystem (databases, forms, auth, admin, APIs)
Dev Server & CLI
fastapi dev (auto-reload) and fastapi run from fastapi-cli in fastapi[standard]
flask run with debugger and reloader; dev server not for production
Production Servers
Uvicorn (fastapi run --workers N or uvicorn --workers N); one process per container recommended on Kubernetes
Gunicorn, Waitress, mod_wsgi, uWSGI, gevent behind a reverse proxy
Request Size Limits
Configurable request body size (0.164.0) and form parsing limits (0.165.0)
MAX_CONTENT_LENGTH, MAX_FORM_MEMORY_SIZE and MAX_FORM_PARTS (3.1.0), per-request max_content_length
Versioning & Stability
0.x semantic versioning: minors may break, patches are fixes; docs say pin the version
Stable semantic versioning on 3.x; releases are infrequent
Testing
TestClient (Starlette/HTTPX); dependency overrides for tests
Built-in test client and CLI runner
Our Run: JSON GET, 1 core
6,026-6,597 req/s (Uvicorn, 1 process); p99 3 ms at 10 clients, 15-16 ms at 50
Gunicorn 1 sync worker: 1,177-1,742 req/s; 1 gthread worker x 8 threads: 2,878-3,196 req/s, p99 16 ms at 10 clients, 62 ms at 50
Our Run: 100 ms I/O wait, 50 clients
async + await asyncio.sleep: 487 req/s, p99 136 ms; def endpoint: ~390 req/s; async + time.sleep: 10 req/s with timeouts
Sync worker: 10 req/s; gthread 8 threads: 78 req/s, p50 609 ms
Our Run: invalid JSON body
422 with 4 field errors and locations; /items/abc also 422
HTML 500 (TypeError, KeyError) without validation code; /items/abc 404 via int converter
Our Run: memory (RSS)
~52-55 MB for one Uvicorn process
~37 MB worker + ~27 MB Gunicorn master

FastAPI

FastAPI is a Python framework for building APIs with standard type hints. It sits on Starlette for routing, requests and WebSockets and on Pydantic for validation and serialisation, and runs on any ASGI server, usually Uvicorn. A path operation declares its parameters and body as typed arguments or Pydantic models; FastAPI validates input, returns structured 422 errors, converts output and publishes an OpenAPI schema with Swagger UI and ReDoc. It is created by Sebastián Ramírez, MIT-licensed and still on 0.x versions, which its docs say may include breaking changes in any minor release. 0.165.0 was released on 18 November 2026; 0.162.6 (13 November) dropped Python 3.10.

Pros

  • Type hints drive validation, serialisation, editor completion and docs from one declaration; invalid input gets a 422 listing every error with its location
  • Automatic OpenAPI 3.1 schema with interactive Swagger UI at /docs and ReDoc, which we confirmed returned 200 with no extra code
  • ASGI and async-first: async endpoints and WebSockets run on one event loop, and plain def endpoints run in a thread pool
  • Highest throughput of the two in our run: about 6,000-6,600 JSON req/s on one core with Uvicorn, and 4,557 req/s for a validated POST
  • Built-in dependency injection with Depends, including yield cleanup and, since 0.163.0, per-dependency concurrency limits
  • fastapi[standard] installs Uvicorn and the fastapi CLI (fastapi dev with reload, fastapi run for production)

Cons

  • Still 0.x: minor releases ship breaking changes (JSON null handling in 0.151.0, removed **extra in 0.155.0, form booleans in 0.162.0), so you must pin the exact version
  • Blocking calls inside async def stall every request on the worker: in our test time.sleep in an async endpoint dropped throughput to 10 req/s with timeouts
  • API-focused: no template layer, forms framework, admin or ORM of its own; server-rendered sites need Jinja and other pieces wired in by hand
  • More moving parts (Starlette, Pydantic, AnyIO, Uvicorn) and a heavier import: about 0.39 s for our small app versus 0.15 s for Flask

Best For

JSON and REST APIs, typed request/response contracts, services with many concurrent I/O calls, WebSockets, microservices that need OpenAPI clients, and ML or LLM model-serving endpoints.

Flask

Flask is a WSGI web framework from the Pallets project, built on Werkzeug for HTTP and Jinja for templates. Its core stays deliberately small (the docs explain that micro means a simple, extensible core, not a small application) and features such as databases, forms, authentication and API schemas come from community extensions. Views are plain functions mapped to routes; async def views are supported, but each request still occupies a worker for its duration. Flask is BSD-3-Clause licensed and supports Python 3.9 and newer. The current release is 3.1.3 from 18 February 2026, a security fix; 3.1.0 (November 2024) added form size limits and secret-key rotation.

Pros

  • Small, stable 3.x API: few breaking changes, and code and tutorials from years ago still apply
  • Excellent for server-rendered sites: Jinja templates, sessions, flashing and blueprints are part of the core
  • Large extension ecosystem for databases, forms, auth, admin and APIs, so you choose each piece
  • Lighter at import and in memory in our run: 0.15 s app import, ~37 MB worker plus ~27 MB Gunicorn master
  • Runs on mature WSGI servers (Gunicorn, Waitress, mod_wsgi, uWSGI) and can use gevent for concurrency

Cons

  • No built-in request validation or API docs: malformed JSON in our test raised TypeError/KeyError and returned an HTML 500 until we add validation code or an extension
  • WSGI ties up one worker per request even for async views; with a 100 ms wait, a threaded worker managed 78 req/s versus 487 for async FastAPI
  • Lower raw throughput in our run: about 1,200-1,700 req/s on one sync worker and 2,900-3,200 with 8 threads, versus 6,000+ for FastAPI
  • Gunicorn's sync worker closes the connection after every response (we saw Connection: close), so throughput depends on worker class and count

Best For

Server-rendered web apps, admin tools and internal dashboards, existing Flask codebases, apps that lean on mature extensions, and teams that value a stable API over the newest features.

ASGI versus WSGI: why the two behave differently under load

Most of the practical differences come from the server interface. Flask is a WSGI application: the server hands one request to one worker, the worker runs your view and returns a response, and only then is that worker free again. Flask supports async def views, but its docs are explicit that each request still ties up one worker; Flask starts an event loop in a thread for the view and returns the result. That is fine for CPU-light pages and moderate traffic, and Gunicorn's thread and gevent workers raise concurrency, but a worker that waits on a slow database or HTTP call is a worker that serves nobody else. For async-heavy apps the Flask docs point to Quart, an ASGI reimplementation of Flask. FastAPI is an ASGI application on Starlette. An async def endpoint that awaits I/O gives the event loop back, so one Uvicorn process can keep many requests in flight. Plain def endpoints are run in a thread pool so blocking code does not freeze the loop. The trap is the third case: blocking code inside async def. In our test an async endpoint that called time.sleep(0.1) fell to 10 requests per second with timeouts, exactly as slow as a single Flask sync worker, because it blocked the only event loop. FastAPI rewards using async libraries and punishes mixing them up.

What we measured on one core

On 21 November 2026 we installed fastapi[standard] 0.165.0 (Starlette 1.10.0, Pydantic 2.14.4, Uvicorn 0.54.0 with uvloop and httptools) and Flask 3.1.3 with Gunicorn 27.0.1 on Python 3.13.18 in a 2-vCPU sandbox. Each server was pinned to one core and autocannon 8.0.0 ran on the other for 10 seconds per test. A JSON GET that returns a small dict reached 6,026-6,373 req/s on FastAPI with 50 connections (p99 15-16 ms) and 6,597 req/s with 10 (p99 3 ms). A POST validated by a nested Pydantic model reached 4,557 req/s. Flask on one Gunicorn sync worker served 1,177-1,742 req/s depending on the run and client count; its latency numbers were not usable because the sync worker answers with Connection: close, so the client spends its time reconnecting. One gthread worker with 8 threads served 2,878-3,196 req/s (p99 16 ms at 10 connections, 62 ms at 50). With a simulated 100 ms I/O wait and 50 clients, FastAPI async with await asyncio.sleep handled 487 req/s (p99 136 ms), a FastAPI def endpoint about 390 req/s, the threaded Flask worker 78 req/s and the sync worker 10 req/s. FastAPI's own benchmarks page cites TechEmpower results that put FastAPI on Uvicorn below only Starlette and Uvicorn among Python frameworks; our numbers are single runs on shared hardware, not a benchmark.

Validation, schemas and docs: built in versus bring your own

This is the biggest day-to-day difference. In FastAPI we declared an Order model with a customer_id integer and a list of lines, each with a sku of at least three characters and a qty between 1 and 100. Sending customer_id as "x", a one-letter sku, qty as "two" and a zero quantity returned a 422 with four errors, each with a type, a message and a location such as ["body", "lines", 0, "sku"]. A non-integer path parameter also returned a 422. The same app published an OpenAPI 3.1.0 document listing the Line, Order, HTTPValidationError and ValidationError schemas, and /docs served Swagger UI, all without extra code. Recent releases keep extending this: parameter models for query, header, cookie and form data, unions of form models, and configurable body size (0.164.0) and form parsing (0.165.0) limits. The equivalent Flask view read request.get_json() and trusted it. The same bad body raised a TypeError when summing quantities, and a missing key raised a KeyError; both came back as an HTML 500 page and a stack trace in the log. Flask's int route converter did turn /items/abc into a 404. Flask can do everything FastAPI does here, but you choose and wire the pieces: Pydantic or marshmallow for validation, an extension for OpenAPI, and error handlers that return JSON. For APIs that is real work you repeat in every project.

Stability, versioning and the cost of upgrades

The two projects move at very different speeds. Flask is on a stable 3.x line with infrequent releases: 3.1.0 arrived in November 2024 with form memory and part limits, per-request max_content_length and SECRET_KEY_FALLBACKS for key rotation, and the latest release, 3.1.3 on 18 February 2026, fixed a session security issue (GHSA-68rp-wp8r-4726). It supports Python 3.9 and newer. FastAPI is still versioned 0.x, and its documentation says plainly that any minor release may contain breaking changes, that patch releases are for fixes, and that you should pin the exact version you have tested. The release notes show why. Between 20 October and 18 November 2026 there were more than twenty releases. 0.151.0 started distinguishing an explicit JSON null from an omitted body value, 0.155.0 removed the deprecated **extra keyword arguments from parameter functions, 0.160.0 applied each parameter model's extra setting to sibling fields, 0.162.0 changed how omitted boolean form fields are handled, and 0.162.6 dropped Python 3.10. None of these is dramatic alone, but together they mean FastAPI projects need a lockfile, a test suite that exercises validation edge cases, and a habit of reading the changelog before upgrading. Flask projects mostly face upgrades in their extensions rather than in Flask itself.

Deployment, memory and choosing a stack

Deployment looks similar on the surface and differs underneath. FastAPI's documented path is fastapi run or Uvicorn with --workers N for several processes on one machine, while its docs recommend a single Uvicorn process per container on Kubernetes and letting the cluster handle replication. fastapi[standard] installs Uvicorn with uvloop and httptools plus the fastapi CLI; fastapi dev adds auto-reload for development. Flask's docs list Gunicorn, Waitress, mod_wsgi, uWSGI and gevent, all behind a reverse proxy, and warn not to use the built-in development server in production. Our sync-versus-gthread numbers show why the worker class matters: on one core, threads roughly doubled Flask's JSON throughput and cut latency at 50 connections to a p99 of 62 ms. Memory was modest for both: one Uvicorn process with our FastAPI app sat at 52-55 MB, and Flask used about 37 MB per Gunicorn worker plus 27 MB for the master. Importing our small FastAPI app took about 0.39 s against 0.15 s for Flask, which matters only for serverless cold starts and CLI tools. Neither framework has a licence cost: FastAPI is MIT and Flask BSD-3-Clause. If you want batteries included with an ORM and admin, compare our FastAPI vs Django and Django vs Flask pages; for Node.js alternatives see Express vs Fastify and NestJS vs Express.

Verdict

Pick FastAPI when you are building a JSON API. Declaring request models with type hints gives you validation with precise 422 errors, response serialisation and an OpenAPI 3.1 schema with Swagger UI from the same code, and ASGI lets one process wait on many slow database or HTTP calls at once: in our run it served about four times Flask's sync-worker throughput on one core and over six times the threaded Flask rate when each request waited 100 ms. Pin the exact FastAPI version and read the release notes before upgrading, because 0.x minors still change behaviour, and never call blocking libraries from async def endpoints (use def or an async client). Pick Flask for server-rendered web apps, internal tools and admin pages, projects built around Flask extensions, and teams that want a slow-moving, stable 3.x API; add validation (Pydantic or an extension) before exposing JSON endpoints, and run Gunicorn with threads or several workers rather than one sync worker. If you have a working Flask app, there is little reason to rewrite it; put new API services on FastAPI instead.

All Comparisons

FastAPI vs Flask — FAQ

Common questions answered from the comparison above

Is FastAPI faster than Flask?

In our single-core run, yes: FastAPI on Uvicorn served about 6,000-6,600 JSON requests/s, Flask on one Gunicorn sync worker about 1,200-1,700 and with 8 threads about 2,900-3,200. With a 100 ms I/O wait the gap grew to 487 versus 78 req/s, because async FastAPI keeps many requests in flight on one process.

Should I migrate from Flask to FastAPI?

Only with a concrete reason, such as needing request validation and OpenAPI docs for a growing API, or many concurrent slow I/O calls. A working Flask app with server-rendered pages and extensions gains little from a rewrite. A common path is to build new API services on FastAPI and leave the Flask app in place.

Does Flask support async?

Yes, since Flask 2.0 you can write async def views, but Flask stays a WSGI framework: its docs say each request still ties up one worker, with an event loop started in a thread for the view. For async-heavy apps the Flask docs suggest Quart, an ASGI reimplementation of Flask.

Why does FastAPI return 422 instead of 400?

FastAPI returns 422 Unprocessable Entity when the request is well-formed HTTP but fails validation against your type hints or Pydantic models. The body lists every error with its type, message and location, for example ["body", "lines", 0, "sku"]. You can override the handler if your API contract requires 400.

Is FastAPI production-ready if it is still version 0.x?

It is widely used in production, but 0.x matters: the FastAPI docs say minor releases may contain breaking changes and recommend pinning the exact version. Releases between October and November 2026 changed JSON null handling, removed deprecated parameter arguments and dropped Python 3.10, so use a lockfile and test before upgrading.

Which Python versions do FastAPI and Flask support?

FastAPI 0.165.0 requires Python 3.11 or newer (3.10 was dropped in 0.162.6 on 13 November 2026). Flask 3.1.3 supports Python 3.9 and newer.

Get the next comparison by email

One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.