Introduction
web3.js and ethers.js are two javascript libraries that application use to interact with the Ethereum blockchain, which includes smart contracts and also to process transactions on the network. In this article, we’ll dive into the difference between these two libraries and help you understand which library to use.
But before we dive into the difference between web3.js and ethers.js. Let’s first understand what these libraries are. So, let’s get started!
What is web3.js?
web3.js is a javascript library that allows us to interact with the Ethereum blockchain, This interaction could be sending Ether from one account to another, reading and writing data from the blockchain with smart contracts, and so much more!

web3.js was created by Gavin Wood, back in 2015. Back then web3.js was a vital tool that allowed developers to build their own Ethereum blockchain quickly. Nowadays, A lot of startups use web3.js like Terra, Chaingrep, and Huddle01.
What is ethers.js?
ether.js is also a javascript library that allows the user to interact with the Ethereum blockchain, But the main difference between the two is that ether.js is a lightweight library. This Library was primarily created for and used with ethers.io, but nowadays the library can be used like the web3 library.

web3.js vs ethers.js – comparison
Popularity
As web3.js has been around for a long time compared to ethers.js, it’s popular. But when we see the daily downloads of both of the libraries, ethers.js is a clear winner here. This also shows the speed of its growth.
Size
ethers.js is very small compared to the web3.js library. This is because ethers.js is exclusively made to work with the Ethereum network which explains why ethers.js is smaller.
The smaller size is due functionality that both libraries offer. ethers.js allows the developer only to interact with the Ethereum network while web3.js is not just for the Ethereum network, it can also allow us to interact with decentralized file storage, generate cryptographically strong pseudo-randoms, etc.
Security
Security is a really important thing that concerns all blockchain developers because in the blockchain space there are a lot of areas where these blockchains can be exploited. As there’s an economic incentive to exploit it, there’s a larger risk of an attack.
As ethers.js has a lot of inbuilt features that help the security aspect of ethers.js, One of which is the no of tests it has, which we will be talking about in a while, also it has separate handling of key-management and state which increases security. ethers.js also has a very active community that searches and deals with these bugs and security threats.
web3.js has had a huge security breach as it has been around for a long time, one notable security breach involves the wormhole bridge which is a protocol that allowed users and applications to move assets between blockchains. Due to this vulnerability, a malicious hacker was able to hint at 120,000 ETH in exploiting a bridge to the Solana blockchain.
Documentation
While the documentation of both libraries is extensive and very well written. If you are getting started with blockchain, ethers.js has very easy-to-understand and concise documentation that allows developers to get into blockchain much more easily.
Also, Web3.js might be hard to get into, but due to web3.js being around since 2015, its documentation has been around for far longer, and thus an experienced developer will more likely enjoy this, but new users may find it hard to delve into the documentation.
Web Performance
If performance is important to you, ethers.js is something you should consider. ethers.js is smaller in comparison to web3.js as we discussed earlier. but if performance is not important to your project you can skip this point.
Testing
Ethers.js has a very large number of test cases(23k tests and counting), these tests are run every time new code is added to the repository automatically. These tests make the library more secure, safe, and reliable.
License
Lastly, Ethers.js is entirely MIT licensed, and this also includes all its dependencies. MIT license is the most permissive open source license, which allows us, developers to do pretty much anything we want to do with ethers.js, as long as we include the copyright notice.
Web3.js on the other hand has an LGLv3 license, which is more restrictive than the MIT license. But the license completely depends on your use case, so consider looking into more details for the MIT license and the LGPLv3 license.
Summary
From this, we can conclude that both libraries are capable of helping us get the job done. But all the difference lies in your usage.
Ethers.js has a smaller size. thus, takes less time to load up. therefore, has better web performance. Its documentation is far easier to understand and there’s less code to write for ethers.js compared to web3.js, thus good for someone who wants to get into the blockchain. It also has better security because of the test cases and separate handling of key management.
As for web3.js, it has been around since 2015. Thus, there’s more extensive documentation for it out there, which is something a seasoned developer might enjoy. web3.js is best for the blockchain-focused firm, as it has been the most used Ethereum library.