Express vs Fastify
The default Node.js framework vs the one that actually cares about performance. Both build APIs. One does it faster.
Fastify
Fastify is Express done right. 2x faster, built-in validation with JSON Schema, proper plugin system, and TypeScript support that doesn't feel bolted on. Express is the jQuery of Node backends — everyone learned it, but there are better options now.
Express Is The Default, Not The Best
Express is the most popular Node.js framework because it was the first good one. Every tutorial uses it. Every bootcamp teaches it. Every Stack Overflow answer assumes it.
But Express hasn't had a major release since 2014 (Express 4). Version 5 has been in alpha for years. The middleware pattern hasn't changed. The error handling is still callback-based. It feels like maintaining a museum exhibit.
Fastify's Speed Advantage
Fastify processes requests roughly 2x faster than Express. This comes from JSON serialization optimization (using fast-json-stringify), schema-based validation, and a more efficient routing algorithm.
For most small apps, you won't notice. But at 10K+ requests per second, the difference is real and it compounds. Less CPU per request means fewer servers means lower bills.
The Plugin System Is Better
Express middleware is a flat chain. Everything runs in order, sharing a mutable req and res. It works, but it's hard to encapsulate and easy to create conflicts.
Fastify's plugin system provides encapsulation. Each plugin gets its own scope. You can register routes, decorators, and hooks without polluting the global namespace. It's closer to a real dependency injection system.
Schema Validation For Free
Fastify uses JSON Schema for request/response validation. Define your schema once, get validation, serialization, and automatic documentation.
Express? Bring your own validation (Joi, Zod, express-validator). Write it separately from your route. Hope it stays in sync.
This single feature saves more bugs than any other difference between the two frameworks.
Why Express Persists
Express has the ecosystem. Express has the tutorials. Express has the middleware packages (20,000+ on npm). If you need passport.js, express-session, or any of the thousands of Express middleware packages, they just work.
Fastify can use Express middleware via @fastify/express, but it's a compatibility layer, not native. Some complex middleware doesn't translate perfectly.
Quick Comparison
| Factor | Express.js | Fastify |
|---|---|---|
| Performance | Good | Excellent (~2x faster) |
| Validation | Bring your own | JSON Schema built-in |
| Plugin System | Flat middleware | Encapsulated plugins |
| TypeScript | Via @types/express | First-class support |
| Ecosystem | Massive (10+ years) | Growing |
| Learning Resources | Everywhere | Less common |
| Maturity | Stable but stale | Active development |
The Verdict
Use Express.js if: You need specific Express middleware, your team only knows Express, or you're following a tutorial that uses it.
Use Fastify if: You're building a new API and want better performance, validation, and TypeScript support out of the box.
Consider: NestJS uses Express or Fastify as its HTTP adapter. If you want a full framework, NestJS + Fastify gives you the best of both worlds.
Fastify is Express done right. 2x faster, built-in validation with JSON Schema, proper plugin system, and TypeScript support that doesn't feel bolted on. Express is the jQuery of Node backends — everyone learned it, but there are better options now.
Related Comparisons
Disagree? nice@nicepick.dev