Node.js and Express.js often get mentioned in the same breath, but they're not competing tools — one sits on top of the other.
Node.js
Node.js is a JavaScript runtime that lets JS run outside a browser.
- Ships built-in modules for files, networking, and raw HTTP.
- Lets you build backend services without any extra framework.
- Powers scalable, high-throughput applications at companies like Netflix and Uber.
Express.js
Express is a thin framework built on top of Node.js that removes boilerplate:
- Gives your app a clearer structure.
- Makes routing declarative instead of manual.
- Adds middleware for cross-cutting concerns (auth, logging, parsing).
- Adds convenience methods for HTTP requests and responses.
The same server, two ways
Plain Node.js
const http = require("http");
const server = http.createServer((req, res) => {
if (req.url === "/" && req.method === "GET") {
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("Bookstore API - raw Node.js");
} else {
res.writeHead(404);
res.end("Not Found");
}
});
server.listen(5000, () => console.log("Raw Node server on port 5000"));
With Express
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.send("Bookstore API - built with Express");
});
app.listen(5000, () => console.log("Express server on port 5000"));
Notice how much manual URL/method checking disappears once Express handles routing for you.
Side-by-side comparison
| Express.js | Node.js |
|---|---|
| A web framework built on top of Node.js | A JavaScript runtime for server-side code |
| Adds routing out of the box | You write your own routing logic |
| Ships built-in middleware support | No middleware concept by default |
| Faster to build web apps/APIs with | Requires more boilerplate for the same result |
| Slight framework overhead | Slightly leaner, since it's the bare runtime |
In short: Node.js gives you the engine; Express gives you the steering wheel, pedals, and dashboard.