adm-zip vs extract-zip vs unzip vs unzipper vs yauzl
Node.js Zip File Handling Libraries
adm-zipextract-zipunzipunzipperyauzlSimilar Packages:

Node.js Zip File Handling Libraries

These libraries provide various functionalities for handling ZIP files in Node.js applications. They allow developers to create, extract, and manipulate ZIP archives easily, which is essential for file management, data compression, and packaging applications. Each library has its unique features and use cases, catering to different needs in terms of performance, ease of use, and functionality.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
adm-zip02,165122 kB144a month agoMIT
extract-zip0398-566 years agoBSD-2-Clause
unzip0618-8512 years agoMIT
unzipper047356.6 kB862 years agoMIT
yauzl080397.7 kB15a month agoMIT

Feature Comparison: adm-zip vs extract-zip vs unzip vs unzipper vs yauzl

Ease of Use

  • adm-zip:

    adm-zip offers a very intuitive API that allows developers to easily create and extract ZIP files with minimal code. Its straightforward methods make it accessible for beginners and quick implementations.

  • extract-zip:

    extract-zip is designed specifically for extraction, providing a simple interface that allows users to extract files with just a few lines of code, making it user-friendly for straightforward tasks.

  • unzip:

    unzip provides a very basic API that is easy to understand and use, making it suitable for developers who need a no-frills solution for extracting ZIP files.

  • unzipper:

    unzipper has a slightly steeper learning curve due to its streaming capabilities, but it offers a powerful API for handling files as they are extracted, which can be beneficial for advanced users.

  • yauzl:

    yauzl has a more complex API compared to others, but it offers extensive features for reading ZIP files efficiently, making it suitable for developers who need advanced functionalities.

Performance

  • adm-zip:

    adm-zip is generally efficient for small to medium-sized ZIP files, but it may not perform as well with very large archives due to its in-memory operations.

  • extract-zip:

    extract-zip is optimized for extraction speed and can handle large ZIP files effectively, making it a good choice when performance is critical during file extraction.

  • unzip:

    unzip is lightweight and performs adequately for basic extraction tasks, but it may not be the best choice for performance-intensive applications.

  • unzipper:

    unzipper excels in performance, especially with large files, as it streams data rather than loading everything into memory, which minimizes memory usage and enhances speed.

  • yauzl:

    yauzl is highly efficient for reading large ZIP files, as it is designed to handle files in a streaming manner, allowing for low memory consumption and high performance.

Streaming Support

  • adm-zip:

    adm-zip does not support streaming, as it loads the entire ZIP file into memory, which can be a limitation for large files.

  • extract-zip:

    extract-zip does not provide streaming capabilities; it extracts files in a single operation, which may not be suitable for very large archives.

  • unzip:

    unzip does not support streaming and is limited to simple extraction tasks without the ability to process files on-the-fly.

  • unzipper:

    unzipper supports streaming, allowing developers to handle files as they are extracted. This feature is particularly useful for large files or when integrating with other streams in Node.js.

  • yauzl:

    yauzl offers robust streaming support, enabling developers to read files from ZIP archives in a memory-efficient manner, which is ideal for handling large datasets.

File System Interaction

  • adm-zip:

    adm-zip allows for easy interaction with the file system, enabling users to create and manipulate ZIP files directly from the filesystem with simple methods.

  • extract-zip:

    extract-zip provides basic file system interaction for extracting files to specified directories, making it straightforward to use in file management tasks.

  • unzip:

    unzip allows for basic file system interaction, but it is limited in terms of customization and advanced features for file handling.

  • unzipper:

    unzipper allows for more complex file system interactions, enabling developers to pipe extracted files directly to writable streams, which can be useful for processing files on-the-fly.

  • yauzl:

    yauzl focuses more on reading ZIP files rather than writing, so its file system interaction is limited to reading and streaming files efficiently.

Error Handling

  • adm-zip:

    adm-zip provides basic error handling, but it may not cover all edge cases, which could lead to issues during extraction or creation of ZIP files.

  • extract-zip:

    extract-zip has robust error handling specifically for extraction processes, providing clear error messages when issues arise during file extraction.

  • unzip:

    unzip offers minimal error handling capabilities, which may not be sufficient for complex applications that require detailed error management.

  • unzipper:

    unzipper has comprehensive error handling features, allowing developers to manage errors effectively during streaming and extraction processes, which is crucial for reliability.

  • yauzl:

    yauzl provides detailed error handling for reading ZIP files, allowing developers to catch and manage errors effectively, ensuring a more robust application.

How to Choose: adm-zip vs extract-zip vs unzip vs unzipper vs yauzl

  • adm-zip:

    Choose adm-zip if you need a simple and straightforward solution for creating and extracting ZIP files without complex dependencies. It is easy to use and suitable for quick tasks.

  • extract-zip:

    Select extract-zip when your primary requirement is to extract files from ZIP archives. It is focused solely on extraction, making it lightweight and efficient for that purpose.

  • unzip:

    Opt for unzip if you need a basic and minimalistic approach to extracting ZIP files. It is a simple library that provides essential features without any frills.

  • unzipper:

    Use unzipper if you require streaming capabilities for handling large ZIP files. It allows you to process files as they are extracted, which is useful for performance-sensitive applications.

  • yauzl:

    Choose yauzl for a more advanced and efficient ZIP file reading experience. It is designed for performance and can handle large ZIP files with low memory usage.

README for adm-zip

ADM-ZIP for NodeJS

ADM-ZIP is a pure JavaScript implementation for zip data compression for NodeJS.

Build Status

Installation

With npm do:

$ npm install adm-zip

Electron file system support described below.

What is it good for?

The library allows you to:

  • decompress zip files directly to disk or in memory buffers
  • compress files and store them to disk in .zip format or in compressed buffers
  • update content of/add new/delete files from an existing .zip

Dependencies

There are no other nodeJS libraries that ADM-ZIP is dependent of

Examples

Basic usage

var AdmZip = require("adm-zip");

// reading archives
var zip = new AdmZip("./my_file.zip");
var password = "1234567890";
var zipEntries = zip.getEntries(); // an array of ZipEntry records - add password parameter if entries are password protected

zipEntries.forEach(function (zipEntry) {
    console.log(zipEntry.toString()); // outputs zip entries information
    if (zipEntry.entryName == "my_file.txt") {
        console.log(zipEntry.getData().toString("utf8"));
    }
});
// outputs the content of some_folder/my_file.txt
console.log(zip.readAsText("some_folder/my_file.txt"));
// extracts the specified file to the specified location
zip.extractEntryTo(/*entry name*/ "some_folder/my_file.txt", /*target path*/ "/home/me/tempfolder", /*maintainEntryPath*/ false, /*overwrite*/ true);
// extracts everything
zip.extractAllTo(/*target path*/ "/home/me/zipcontent/", /*overwrite*/ true);

// creating archives
var zip = new AdmZip();

// add file directly
var content = "inner content of the file";
zip.addFile("test.txt", Buffer.from(content, "utf8"), "entry comment goes here");
// add local file
zip.addLocalFile("/home/me/some_picture.png");
// get everything as a buffer
var willSendthis = zip.toBuffer();
// or write everything to disk
zip.writeZip(/*target file name*/ "/home/me/files.zip");

// ... more examples in the wiki

For more detailed information please check out the wiki.

Electron original-fs

ADM-ZIP has supported electron original-fs for years without any user interractions but it causes problem with bundlers like rollup etc. For continuing support original-fs or any other custom file system module. There is possible specify your module by fs option in ADM-ZIP constructor.

Example:

const AdmZip = require("adm-zip");
const OriginalFs = require("original-fs");

// reading archives
const zip = new AdmZip("./my_file.zip", { fs: OriginalFs });
.
.
.