What are the differences between HTTP module and Express.js module ?
Last Updated :
08 Jan, 2025
HTTP and Express both are used in NodeJS for development. In this article, we'll go through HTTP and express modules separately
HTTP: It is an in-build module which is pre-installed along with NodeJS. It is used to create server and set up connections. Using this connection, data sending and receiving can be done as long as connections use a hypertext transfer protocol.
Example: Creating a server using the HTTP module in NodeJS.
index.js
// Importing http module
var http = require('http');
// Create a server object which listens on port 300
http.createServer(function (req, res) {
// Write a response to the client
res.write('Hello World!');
// End the response
res.end();
}).listen(3000);
Run the index.js file using the following command.
node index.js
Output:

Express: Express as a whole is known as a framework, not just as a module. It gives you an API, submodules, functions, and methodology and conventions for quickly and easily typing together all the components necessary to put up a modern, functional web server with all the conveniences necessary for that (static asset hosting, templating, handling CSRF, CORS, cookie parsing, POST data handling, and many more functionalities.
Module Installation: You can install the express module using the following command.
npm i express
Example: Creating a server using the express module in NodeJS.
index.js
// Importing express
const express = require('express');
// Creating instance of express
const app = express();
// Handling GET / Request
app.get('/', function (req, res) {
res.send("Hello World!, I am server created by expresss");
})
// Listening to server at port 3000
app.listen(3000, function () {
console.log("server started");
})
Run the index.js file using the following command.
node index.js
Output:

Difference between HTTP module and Express.js module:
The main difference between Node's HTTP module and Express.js is that Express adds extra functionality for building web applications.
HTTP | Express |
HTTP comes inbuilt along with NodeJS that is, we don't need to install it explicitly. | Express is installed explicitly using npm command: npm install express |
HTTP is not a framework as a whole, rather it is just a module. | Express is a framework as a whole. |
HTTP does not provide function for static hosting, you require to write your own. | Express provide express.static function for static asset hosting. Example: app.use(express.static('public')); |
HTTP is an independent module. | Express is made on top of the HTTP module. |
HTTP module provides various tools (functions) to do things for networking like making a server, client, etc. | Express along with what HTTP does provide many more functions in order to make development easy. |
Similar Reads
What is the difference between Service Directive and Module in Angular ? Angular is a Typescript framework used to build dynamic and Single-Page Applications. This has a strong focus on modularity and reusability of code which helps in creating complex and maintainable applications. At the core, Angular has 3 fundamental building blocks, i.e., Service, Directive and Modu
6 min read
What is the difference between export.create and router.post? export.create and router.post are used in the context of backend frameworks like Express JS. They both are used for handling HTTP requests and operate at different levels within the framework. In this article we will learn about export.create and router.post and see the key differences between them.
3 min read
What is the Difference Between a Module & a Namespace in JavaScript ? The dynamic web's programming language, JavaScript, has changed significantly over time. "Modules" and "Namespaces" are two particularly important architectural elements that have aided in the development of code organization. Modules in JavaScriptModules enable the control and organization of large
3 min read
Difference between app.use() and app.get() in Express.js Express.js, a popular web application framework for Node.js, provides a powerful set of methods for routing HTTP requests. Among these methods, app.use() and app.get() are two fundamental functions that serve different purposes. Understanding their differences is essential for building efficient and
4 min read
Difference between res.send() and res.json() in Express.js? In this article, we will learn about res.send() & res.json(), along with discussing the significant distinction that differentiates between res.send() & res.json(). Let us first understand what is res.send() and res.json() in Express.js? res.send() - The res.send() function is used for sendi
4 min read
Difference between app-level and route-level middleware in Express Middleware functions are functions that have access to the request object ( req ), the response object ( res ), and the next middleware function in the application's request-response cycle. In this article, we will go through app-level and route-level middleware and also see the key differences betw
3 min read