Skip to main content
← Guides

Guide

Express vs Fastify: Node.js Framework Choice 2026

Updated PkgPulse Team10 min read
0

Express vs Fastify on current npm data and Fastify's own benchmark: Express 5 leads on ecosystem and reach, Fastify 5 on schemas, logging and low overhead.

Contents

Pick Express 5 when you want the broadest middleware ecosystem, the most existing code and the least migration work. Pick Fastify 5 when you want JSON Schema validation, built-in Pino logging and encapsulated plugins. Fastify also has a measured but modest speed edge. On Fastify's own single-instance hello-world benchmark, Fastify 5.12.7 serves 89,733 GET requests per second and Express 5.3.0 serves 67,794. That is a 1.3× gap, measured on a trivial route.

Verdict

Both frameworks are current, MIT-licensed and actively maintained, so pick on fit. Express is the default for teams with existing Express code, Express-only middleware or a large pool of Express-trained developers. Fastify is the stronger default for a new JSON API where you will write request and response schemas anyway, because those schemas then drive validation, serialization and OpenAPI docs.

Do not switch a working Express service for speed alone. Fastify's lead holds on its own benchmark, but that benchmark measures framework overhead on a trivial route. In many production APIs, database calls, network calls and business logic cost more than the framework layer.

At-a-glance comparison

CheckExpressFastify
Latest version on npm5.3.05.12.8
npm downloads, 2026-11-03 to 2026-11-09195,493,80422,366,239
GitHub stars69,58437,403
GitHub repository created20092016
LicenseMITMIT
Minimum Node.js (current major)1820
TypeScript typesSeparate @types/express packageBundled (fastify.d.ts)
Request validationBring your own middlewareBuilt in (JSON Schema via Ajv)
LoggingBring your own middlewareBuilt in (Pino)
GET hello-world, Fastify-published67,794 req/s, 14.25 ms89,733 req/s, 10.63 ms
POST JSON echo, Fastify-published44,142 req/s, 22.15 ms69,080 req/s, 13.98 ms

The benchmark rows come from Fastify's own benchmarks page. They are single-instance Node.js results for Express 5.3.0 and Fastify 5.12.7, and Fastify labels them illustrative. Express had about 8.7× more downloads than Fastify in the same week. Download counts include CI installs and transitive dependencies, so treat them as a reach signal, not a count of new projects.

See the live package data at pkgpulse.com/compare/express-vs-fastify, or open the Express and Fastify package pages.

Performance: what the official benchmark shows

Fastify publishes a benchmark of seven Node.js frameworks. Each test runs on a single Node.js instance. The GET test returns { hello: 'world' }. The POST test parses a small JSON body and echoes it back.

Fastify-published testExpress 5.3.0Fastify 5.12.7Fastify's reported gap
GET, requests per second67,79489,7331.3×
GET, latency14.25 ms10.63 ms1.3× lower
GET, throughput12.09 MB/s16.09 MB/s1.3×
POST, requests per second44,14269,0801.6×
POST, latency22.15 ms13.98 ms1.6× lower
POST, throughput7.87 MB/s12.39 MB/s1.6×

These numbers have limits. Fastify runs the benchmark, picks the routes and states that real-world results depend on hardware, Node.js version and workload. The page tells readers to rerun the fastify/benchmarks suite against their own routes. The tests also used Fastify 5.12.7, one patch behind the current npm release.

The POST test adds JSON body parsing and serialization, and Fastify's reported gap widens there from 1.3× to 1.6×.

Sources of the overhead difference

The npm dependency lists show where the two designs differ:

  1. Routing. Fastify depends on find-my-way. Express 5 depends on the separate router package.
  2. Serialization. Fastify depends on fast-json-stringify and its compiler. It can build a serializer from a response schema instead of calling plain JSON.stringify.
  3. Validation. Fastify depends on @fastify/ajv-compiler, so route schemas compile into validators.
  4. Logging. Fastify depends on pino and builds a Pino logger from its logger option.

Workloads where the gap matters

A 1.3× difference in framework overhead matters most when the framework itself is a large share of each request's cost. Examples are thin proxies, gateways, health and webhook endpoints, and JSON APIs that return cached data. On a route that spends most of its time waiting for a database, a few milliseconds of framework latency rarely decides capacity. Measure your own slowest routes before you plan a migration on performance grounds.

Developer experience

Express: minimal and familiar

const express = require('express');
const app = express();

app.get('/api/users/:id', (req, res) => {
  res.json({ id: req.params.id, name: 'John' });
});

app.listen(3000);

Express 5 keeps the familiar API and drops support for Node.js versions before 18. The Express team describes the release as intentionally "boring": it focuses on old Node.js support, security fixes and simpler maintenance. Two changes matter in daily code:

  • Promise support. A rejected promise returned from middleware now reaches Express error handling, so async middleware no longer needs a wrapper to forward errors.
  • Safer path matching. Express 5 removed regular-expression sub-expressions such as /:foo(\\d+) to close a class of ReDoS attacks. All route parameters must now be named.

Express still leaves validation, logging and serialization to you. That keeps the core small, but every team assembles its own stack and conventions.

Fastify: schema-first and structured

const fastify = require('fastify')({ logger: true });

fastify.get('/api/users/:id', {
  schema: {
    params: { type: 'object', properties: { id: { type: 'string' } } },
    response: {
      200: {
        type: 'object',
        properties: { id: { type: 'string' }, name: { type: 'string' } }
      }
    }
  }
}, async (request, reply) => {
  return { id: request.params.id, name: 'John' };
});

fastify.listen({ port: 3000 });

The schema costs more lines, but it does three jobs: it validates input, it controls the serialized response and it feeds @fastify/swagger for OpenAPI docs. Route schemas are optional: Fastify validates input only for the parts of a route you add a schema to. When you do supply a querystring, params, body or response schema, Fastify 5 requires the full JSON Schema format, including the type property. You can replace the default validator, for example with Zod.

Fastify's type definitions ship inside the package, and its type providers infer request types from schemas. Express types come from the separate @types/express package. The trade-off is a steeper start: plugin registration, encapsulation and decorators are concepts Express does not have.

Ecosystem

Express has the larger and older middleware ecosystem, built on the simple (req, res, next) contract. The Express docs list official middleware modules such as body-parser, cors, compression, cookie-parser, morgan, multer, serve-static and session.

Fastify has a core plugin set maintained by the Fastify team. It includes @fastify/auth, @fastify/jwt, @fastify/passport, @fastify/cors, @fastify/helmet, @fastify/rate-limit, @fastify/swagger and @fastify/aws-lambda. A separate community list covers more. Fastify plugins are encapsulated: code registered inside one plugin scope stays in that scope. The Fastify ecosystem also lists @fastify/middie, a middleware engine, and @fastify/express, an Express compatibility layer.

NestJS supports both. NestJS uses @nestjs/platform-express by default and offers @nestjs/platform-fastify as an alternative. Its current docs also add a third option, NodeAdapter, on the node:http module. NestJS recommends it starting with v12.3 and says it will become the default in v13. A NestJS team choosing between Express and Fastify adapters should check that option too.

Decision matrix

Team constraintPickCheck before switching
Large Express codebase that worksExpress 5Upgrade 4 → 5 first. Review regex routes, req.body defaults and removed method signatures.
Depends on Express-only middlewareExpress 5, or Fastify with @fastify/express for a transitionThe compatibility plugin is not a long-term solution and does not support HTTP/2.
New JSON API with typed contractsFastify 5Schemas are optional, but each one you add must be a full JSON Schema with type. Budget time to write them for the routes you validate.
Need OpenAPI docs from codeFastify 5Confirm @fastify/swagger output matches your API gateway or client generator.
Thin proxy or high-volume webhook serviceFastify 5Rerun fastify/benchmarks or load-test your own routes on your Node.js version.
Pinned to Node.js 18Express 5Fastify 5 supports Node.js 20 and later only.
NestJS applicationKeep the current adapterCompare Express, Fastify and the newer NodeAdapter in a staging load test.
Serverless deploymentEitherConfirm the adapter for your platform supports your framework's current major.

Migration notes

If you are moving from Express to Fastify, migrate in steps:

  1. Start new services in Fastify. Do not rewrite working Express code only for speed.
  2. Mount Express code with @fastify/express. The plugin exposes Express's use function and can register a whole Express router or application. It needs the same body parsers you use in Express.
  3. Move routes one at a time. Start with routes where schemas or lower overhead help the most.
  4. Add schemas gradually. Response schemas let Fastify use its compiled serializer. Request schemas add validation.
  5. Remove the compatibility layer. The plugin's own README says it is a transition aid and that Express-specific code should move to Fastify over time.
// Express (old)
import express from "express"
const app = express()
app.use(express.json())

app.get("/packages/:name", async (req, res) => {
  const pkg = await db.findPackage(req.params.name)
  if (!pkg) return res.status(404).json({ error: "Not found" })
  res.json(pkg)
})
app.listen(3000)

// Fastify (new)
import Fastify from "fastify"
const app = Fastify()

app.get<{ Params: { name: string } }>("/packages/:name", async (request, reply) => {
  const pkg = await db.findPackage(request.params.name)
  if (!pkg) return reply.status(404).send({ error: "Not found" })
  return pkg  // Return value is automatically serialized to JSON
})
app.listen({ port: 3000 })

Two Fastify 5 changes often catch migrating teams. First, the logger option no longer accepts a custom logger instance, so pass your own Pino instance as loggerInstance. Second, all Fastify 4 deprecations were removed, so fix v4 deprecation warnings before you upgrade.

Support windows

Express supports only the latest release of each major line. Its support page lists both v5.x and v4.x as ongoing. Fastify supports each major for at least six months after release. It also gives security updates for six more months after the next major ships. Fastify 4 LTS ended on 2025-06-30. Fastify 5 shipped on 2024-09-17 and has no announced end date.

When to choose Express

  • Your team already has Express services, and they meet their load targets.
  • You depend on middleware that has no Fastify-native equivalent.
  • You must stay on Node.js 18 for now.
  • You want the smallest core and prefer to pick your own validation and logging libraries.
  • Your hires and contractors mostly know Express, and onboarding time matters more than framework overhead.

When to choose Fastify

  • You are starting a new JSON API and will define request and response schemas anyway.
  • You want validation, serialization and OpenAPI docs generated from the same schema.
  • You want structured Pino logging without adding middleware.
  • You want plugin encapsulation to keep large APIs split into isolated modules.
  • Framework overhead is a large share of your request cost, and your own load test confirms the gain.

Frequently Asked Questions

Is Fastify faster than Express?

On Fastify's own single-instance benchmark, yes. Fastify 5.12.7 served 89,733 GET requests per second against 67,794 for Express 5.3.0, about 1.3×. On the JSON POST test the gap was about 1.6×. Fastify labels the figures illustrative and says real-world results depend on hardware, Node.js version and workload. Check current package data on PkgPulse.

Should I switch from Express to Fastify?

Not for speed alone. If Express meets your load targets, a migration costs more than it saves. Start new services in Fastify instead, and move existing routes gradually with the @fastify/express compatibility plugin. Then remove that plugin once the Express-specific code is gone.

What is the fastest Node.js framework?

There is no neutral answer. Each project's benchmark measures its own chosen routes. On Fastify's published Node.js benchmark, Fastify leads the GET test, followed by Hono 4.13.14 at 84,930 req/s and H3 2.0.8 at 80,974 req/s. For a broader comparison that includes Bun-first frameworks, read Hono vs Express vs Fastify vs Elysia or compare Fastify vs Hono.

Methodology

This refresh replaced earlier unsourced throughput claims with primary data. Versions come from the npm registry, downloads from the npm downloads API for one fixed week, and stars and creation dates from the GitHub API. Benchmark figures come only from Fastify's published benchmark page, and each row says so. Framework behavior comes from the Express and Fastify docs, release notes and plugin README. PkgPulse did not run its own load test for this guide.

Source notes

Compare more backend packages on PkgPulse: Express vs Fastify, Express vs Hono, Fastify vs Hono or Express vs Koa.