Express is a minimal, unopinionated web framework for Node.js. In simple language, it’s a thin layer that sits on top of Node’s built-in http module and makes building HTTP servers way less painful.
If you’ve ever tried writing a server with raw http.createServer(), you know the drill — parsing URLs, reading request bodies, matching routes by hand, sending headers manually. Express handles all that boring plumbing for us.
Why we use it
The Node http module is powerful but low-level. Even sending a JSON response means setting headers, calling JSON.stringify, calling res.end. Express gives us:
- Routing —
app.get('/users', handler)instead of parsingreq.urlourselves - Middleware pipeline — a clean way to chain logic (auth, logging, body parsing)
- Request/response helpers —
res.json(),req.params,req.query - Huge ecosystem — thousands of middlewares on npm (cors, helmet, morgan, etc.)
Think of it like jQuery for HTTP servers — it’s not magic, it just wraps the ugly parts.
”Unopinionated” — what that means
Express doesn’t force a folder structure, ORM, validation library, or anything else. You bring your own pieces. That’s a double-edged sword — great flexibility, but two Express codebases at two companies can look completely different.
Compare that to NestJS or Rails, which dictate where things go. Express says: “Here’s routing and middleware. Figure out the rest.”
Hello World
npm init -y
npm install express
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello World');
});
app.get('/users/:id', (req, res) => {
res.json({ id: req.params.id, name: 'Manish' });
});
app.listen(3000, () => {
console.log('Server running on http://localhost:3000');
});
That’s a full HTTP server. Four lines of actual logic. The same thing in raw http would be 30+ lines.
What Express is NOT
- Not a full framework — no ORM, no templating opinion, no auth built-in
- Not async-first in design — it predates async/await, so error handling needs some care (we’ll cover this in middleware notes)
- Not the fastest — Fastify benchmarks ~2x faster, but Express is fast enough for 99% of apps
When to pick Express
- Small to medium REST APIs
- You want maximum flexibility
- The team already knows it (huge community, easy hiring)
- You need a specific middleware that only exists for Express
For high-throughput services or strict structure, we’d look at Fastify or NestJS — covered in the next note.