NestJS is what I write at work. At 90Pixel I build backend services in Node.js, NestJS and TypeScript on PostgreSQL, and at my previous job I built NestJS services that handled over 100 million requests a day under 200 ms. I've also shipped plain Express, including the setup in my post on deploying an Express app on Vercel. In this NestJS vs Express comparison I write the same small API in both, because the two solve different problems and the code shows it better than a feature list.

By default, NestJS runs on top of Express. The NestJS docs say Nest uses the ExpressAdapter from @nestjs/platform-express when you don't pass an adapter. So Express handles HTTP, and Nest gives you the structure you build on top of it.

What is the difference between NestJS and Express?

Express is a small routing and middleware library. You get app.get(), app.use(), request and response objects, and that's it. Where files go, how you validate input, how you share a database connection, how you test: all your decisions.

NestJS is a framework with opinions about all of those. You write modules, controllers and providers, wire them with dependency injection, and use decorators for routes, validation, guards and interceptors. It looks a lot like Angular on the server, which is where the idea came from.

Current versions at the time of writing: Express 5.3.0 and NestJS 12.6.0. Express 5 is the line to use now. Its biggest change is that a rejected promise in an async handler goes to your error middleware, as if you had called next(err), per the Express 5 migration guide. NestJS 11 moved its Express adapter to Express 5, and NestJS 12 ships its core packages as ESM.

The same endpoint in Express and NestJS

A small users API with two routes: POST /users validates the body and creates a user, GET /users/:id returns one or a 404. I keep the storage in memory so the framework code is what you're looking at.

Express 5

// src/app.ts
import express, { type NextFunction, type Request, type Response } from "express";
import { z } from "zod";

type User = { id: string; email: string; name: string };

const users = new Map<string, User>();

const CreateUser = z.object({
  email: z.email(),
  name: z.string().min(1),
});

export const app = express();
app.use(express.json());

app.post("/users", async (req, res) => {
  const parsed = CreateUser.safeParse(req.body);
  if (!parsed.success) {
    res.status(400).json({ errors: parsed.error.issues });
    return;
  }

  const user = { id: crypto.randomUUID(), ...parsed.data };
  users.set(user.id, user);
  res.status(201).json(user);
});

app.get("/users/:id", async (req, res) => {
  const user = users.get(req.params.id);
  if (!user) {
    res.status(404).json({ message: "User not found" });
    return;
  }
  res.json(user);
});

app.use((err: Error, _req: Request, res: Response, _next: NextFunction) => {
  console.error(err);
  res.status(500).json({ message: "Internal server error" });
});
// src/server.ts
import { app } from "./app";

app.listen(3000);

That's the whole API in one readable file. I picked zod for validation, but Express doesn't care: Joi, Valibot or hand-written checks all work. When the routes grow you'll split them into express.Router() files, and when the database arrives you'll decide how handlers get access to it. Two Express codebases rarely answer those questions the same way.

NestJS

// src/users/create-user.dto.ts
import { IsEmail, IsNotEmpty } from "class-validator";

export class CreateUserDto {
  @IsEmail()
  email!: string;

  @IsNotEmpty()
  name!: string;
}
// src/users/users.service.ts
import { Injectable, NotFoundException } from "@nestjs/common";
import { CreateUserDto } from "./create-user.dto";

type User = { id: string; email: string; name: string };

@Injectable()
export class UsersService {
  private readonly users = new Map<string, User>();

  create(dto: CreateUserDto): User {
    const user = { id: crypto.randomUUID(), ...dto };
    this.users.set(user.id, user);
    return user;
  }

  findOne(id: string): User {
    const user = this.users.get(id);
    if (!user) throw new NotFoundException("User not found");
    return user;
  }
}
// src/users/users.controller.ts
import { Body, Controller, Get, Param, Post } from "@nestjs/common";
import { CreateUserDto } from "./create-user.dto";
import { UsersService } from "./users.service";

@Controller("users")
export class UsersController {
  constructor(private readonly users: UsersService) {}

  @Post()
  create(@Body() dto: CreateUserDto) {
    return this.users.create(dto);
  }

  @Get(":id")
  findOne(@Param("id") id: string) {
    return this.users.findOne(id);
  }
}
// src/users/users.module.ts
import { Module } from "@nestjs/common";
import { UsersController } from "./users.controller";
import { UsersService } from "./users.service";

@Module({
  controllers: [UsersController],
  providers: [UsersService],
})
export class UsersModule {}
// src/app.module.ts
import { Module } from "@nestjs/common";
import { UsersModule } from "./users/users.module";

@Module({ imports: [UsersModule] })
export class AppModule {}
// src/main.ts
import { ValidationPipe } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module";

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.useGlobalPipes(new ValidationPipe({ whitelist: true }));
  await app.listen(3000);
}
bootstrap();

Six files instead of two, plus class-validator and class-transformer for the ValidationPipe. In return, a few things are already decided. A POST returns 201 without you writing it. A thrown NotFoundException becomes a 404 JSON response with statusCode, message and error. An invalid body is rejected with a 400 before the controller runs, and whitelist: true strips fields that aren't on the DTO. And every Nest project puts these pieces in the same places.

On a two-route API the Express version is clearly nicer to read. The Nest version pays off later, when there are many modules, several services need the same database client, and you want to swap one of them out in a test.

How does testing compare?

In Express you usually test through HTTP with supertest, and mock dependencies at the module level:

import request from "supertest";
import { app } from "./app";

it("returns 404 for an unknown user", async () => {
  await request(app).get("/users/does-not-exist").expect(404);
});

In Nest the same HTTP test works, and dependency injection adds a second option: build a testing module and replace any provider.

import { Test } from "@nestjs/testing";
import { UsersController } from "./users.controller";
import { UsersService } from "./users.service";

it("asks the service for the user", async () => {
  const findOne = vi.fn().mockReturnValue({ id: "1", email: "a@b.co", name: "A" });

  const moduleRef = await Test.createTestingModule({
    controllers: [UsersController],
    providers: [{ provide: UsersService, useValue: { findOne } }],
  }).compile();

  moduleRef.get(UsersController).findOne("1");
  expect(findOne).toHaveBeenCalledWith("1");
});

overrideProvider() does the same for a whole app module, which is how you swap a real payment client or mail sender in end-to-end tests without touching the code under test.

What does a real NestJS module look like?

Modules are where Nest differs most from Express, so here's one I maintain: nest-cloudflare-turnstile, a Cloudflare Turnstile captcha guard. You register it once:

import { TurnstileModule } from "nest-cloudflare-turnstile";

@Module({
  imports: [
    TurnstileModule.forRoot({
      secretKey: process.env.TURNSTILE_SECRET_KEY,
    }),
  ],
})
export class AppModule {}

Then protect any route with a decorator:

@Post("login")
@TurnstileCaptcha()
login() {
  // runs only after Cloudflare accepted the token
}

The guard reads the token from the cf-turnstile-response field, checks it with Cloudflare and rejects the request with a 400 before the handler runs. Because it's a Nest guard and not Express middleware, the same package works on NestJS 10, 11 and 12, on the Express and Fastify adapters, and on GraphQL resolvers and WebSocket gateways.

In Express you'd write it as middleware:

async function turnstile(req: Request, res: Response, next: NextFunction) {
  const token = req.body?.["cf-turnstile-response"];
  if (!token) {
    res.status(400).json({ message: "Missing captcha" });
    return;
  }

  const result = await fetch(
    "https://challenges.cloudflare.com/turnstile/v0/siteverify",
    {
      method: "POST",
      headers: { "content-type": "application/json" },
      body: JSON.stringify({ secret: process.env.TURNSTILE_SECRET_KEY, response: token }),
    },
  ).then((r) => r.json());

  if (!result.success) {
    res.status(400).json({ message: "Captcha failed" });
    return;
  }
  next();
}

app.post("/login", turnstile, loginHandler);

That's fine for one app. It only works on Express, though, and hostname checks, test keys and retries are left for you to write.

Is NestJS slower than Express?

On the default adapter, NestJS runs Express underneath, so the HTTP parsing and routing are Express's. What Nest adds per request depends on what you register: each guard, pipe and interceptor is code that runs. I haven't found a benchmark from an official source that isolates that overhead on its own, so I won't give you a number.

What the NestJS docs do publish is a comparison between its own adapters. Measured with wrk, 100 connections and Node.js 24, on a plain GET route, a GET with a parameter and a POST with a JSON body, Nest handled about 50% more requests per second on the new NodeAdapter (@nestjs/platform-node, built on node:http) than on the ExpressAdapter, and about 5% more than on the FastifyAdapter. The docs recommend NodeAdapter from v12.3 and say it becomes the default in v13. Switching is one line in main.ts:

import { NodeAdapter } from "@nestjs/platform-node";

const app = await NestFactory.create(AppModule, new NodeAdapter());

The same page makes the point that matters most in practice: a route that waits on a database or another service spends most of its time waiting, so the adapter matters for light routes at high request rates. The slow part of a busy API is usually a query, an N+1 loop or a missing index, not the framework. Measure your own routes before choosing a framework for speed. If you want to see latency per route, my Grafana and Prometheus setup is a good start.

NestJS vs Express: comparison table

Express 5NestJS 12
What it isRouting and middleware libraryFramework with modules and dependency injection
HTTP layerItselfExpress by default, also Fastify or node:http adapters
Project structureUp to youModules, controllers, providers
ValidationAny library, wired by handPipes, with class-validator or Standard Schema
ErrorsError middleware, async errors forwarded in v5Exception classes and exception filters
Testingsupertest, module mockssupertest plus Test.createTestingModule
GraphQL, WebSockets, queuesSeparate librariesFirst-party packages using the same DI
Learning curveAn afternoonDays to weeks, decorators and DI included
Best fitSmall services, serverless functions, prototypesLarge APIs, teams, long-lived products

When should you choose Express, and when NestJS?

Choose Express when the service is small and will stay small: a webhook receiver, a proxy, a serverless function, a prototype you want running today. It's also right when you want full control over structure and your team agrees on one. My Express on Vercel setup is a good example of where Nest would be overhead.

Choose NestJS when the API will grow, when several people work on it, or when it needs more than HTTP. Nest's GraphQL, WebSocket, microservice and queue integrations share one DI container and one set of guards and pipes, so authentication you wrote once applies to all of them. Because every module has the same shape, someone new to the codebase knows where to look.

If you're starting a backend that a team will maintain for years, I'd start with NestJS. If you're writing one endpoint, write Express. If you need a NestJS developer for a backend like that, I take on work: see hire.

On the frontend side I compared Nuxt vs Next the same way.

FAQ

Is NestJS built on Express?

By default, yes. Nest uses @nestjs/platform-express unless you pass another adapter. It also supports Fastify and, in recent v12 releases, a NodeAdapter built directly on node:http.

Is NestJS faster than Express?

On the Express adapter, Nest runs on Express and adds its own per-request steps, so it isn't faster. The Nest docs report that their NodeAdapter handles about 50% more requests per second than the ExpressAdapter on their benchmark routes. For routes that wait on a database, the difference is small.

Should I learn Express before NestJS?

It helps. Nest's requests, responses and middleware are Express's on the default adapter, and you'll debug faster if you know what's underneath.

Can I use Express middleware in NestJS?

Yes. On the Express adapter, app.use() accepts Express middleware, and Nest's own middleware has the same (req, res, next) signature. The docs say much Express middleware also works unchanged on the NodeAdapter.

Is NestJS overkill for a small project?

For a handful of routes, usually yes. The structure pays off when the codebase or the team grows.