archiver vs jszip vs adm-zip vs zip-local
Node.js Zip File Libraries Comparison
1 Year
archiverjszipadm-zipzip-localSimilar Packages:
What's Node.js Zip File Libraries?

Zip file libraries in Node.js provide developers with tools to create, read, and manipulate zip files within their applications. These libraries simplify the process of handling compressed files, making it easier to bundle resources, manage file uploads, and facilitate data transfer. Each library has its unique strengths, catering to different use cases, such as performance, ease of use, and feature sets, allowing developers to choose the best fit for their project requirements.

NPM Package Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
archiver5,084,9952,83743.1 kB14910 months agoMIT
jszip4,496,9059,847762 kB420-(MIT OR GPL-3.0-or-later)
adm-zip3,010,0642,068121 kB1404 months agoMIT
zip-local12,21612057.1 kB13-
Feature Comparison: archiver vs jszip vs adm-zip vs zip-local

Ease of Use

  • archiver:

    archiver has a more complex API due to its extensive features, but it offers powerful capabilities for those who need advanced functionalities. It may require more initial setup and understanding of streams, but it pays off for larger applications.

  • jszip:

    jszip is designed to be user-friendly, with a clear and concise API that allows developers to create and manipulate zip files easily. It is well-documented, making it accessible for both beginners and experienced developers.

  • adm-zip:

    adm-zip provides a very simple and intuitive API, making it easy for developers to quickly create and extract zip files with minimal code. Its straightforward methods allow for rapid implementation without a steep learning curve.

  • zip-local:

    zip-local is very easy to use, with a minimalistic approach that allows developers to zip and unzip files with just a few lines of code. Its simplicity is a major advantage for quick tasks.

Performance

  • archiver:

    archiver excels in performance, especially with large files, as it streams data rather than loading everything into memory. This makes it highly efficient for generating large zip files on-the-fly, reducing memory consumption.

  • jszip:

    jszip performs well for both small and medium-sized zip files, but it can be slower than archiver when handling very large files due to its in-memory processing. However, it is still a solid choice for general use cases.

  • adm-zip:

    adm-zip is suitable for small to medium-sized zip files but may not perform as well with very large files or datasets due to its in-memory processing. It is best used for simpler tasks where performance is not a critical concern.

  • zip-local:

    zip-local offers decent performance for local file operations, but it may not be the best choice for very large datasets. It is optimized for simplicity rather than raw performance.

Compression Formats

  • archiver:

    archiver supports multiple compression formats, including zip, tar, and gzip. This versatility makes it suitable for a wide range of applications that require different types of compressed files.

  • jszip:

    jszip specifically focuses on the zip format, providing a robust implementation for creating and manipulating zip files. It does not support other compression formats, which may limit its use in some scenarios.

  • adm-zip:

    adm-zip primarily supports the standard zip format and does not offer options for other compression formats. It is focused on ease of use rather than flexibility in compression methods.

  • zip-local:

    zip-local is limited to the zip format and does not provide support for other compression types. It is designed for straightforward zip file operations.

Streaming Support

  • archiver:

    archiver offers excellent streaming support, allowing developers to create zip files on-the-fly without loading entire files into memory. This is particularly useful for web applications that need to serve large files efficiently.

  • jszip:

    jszip does not support streaming natively, as it operates primarily in memory. This can be a drawback for applications that require efficient handling of large datasets or files.

  • adm-zip:

    adm-zip does not support streaming, which can be a limitation for applications that need to handle large files or generate zip files dynamically. It processes files in memory, which may lead to higher memory usage.

  • zip-local:

    zip-local does not provide streaming capabilities and is best suited for simpler, local file operations where performance is not a major concern.

Browser Compatibility

  • archiver:

    archiver is primarily a Node.js library and does not work in the browser. It is intended for server-side use where advanced zip file creation is needed.

  • jszip:

    jszip is unique in that it works seamlessly in both Node.js and browser environments. This makes it an excellent choice for applications that require zip file manipulation on the client side.

  • adm-zip:

    adm-zip is designed for Node.js and is not suitable for browser environments. It is focused on server-side operations and does not offer browser compatibility.

  • zip-local:

    zip-local is also designed for Node.js and does not support browser usage. It is focused on local file management tasks.

How to Choose: archiver vs jszip vs adm-zip vs zip-local
  • archiver:

    Select archiver if you require advanced features like streaming support, multiple compression formats, and the ability to create large zip files efficiently. It is ideal for applications that need to generate zip files on-the-fly or handle large datasets.

  • jszip:

    Opt for jszip if you need a powerful library that works seamlessly in both Node.js and the browser. It supports a wide range of zip file operations and is particularly useful for applications that require client-side zip file handling or manipulation.

  • adm-zip:

    Choose adm-zip if you need a straightforward and easy-to-use library for basic zip file operations, such as creating and extracting zip files without complex configurations. It is particularly useful for small projects or scripts where simplicity is key.

  • zip-local:

    Choose zip-local if you prefer a library that offers a simple API for zipping and unzipping files with minimal overhead. It is suitable for local file management tasks and is easy to integrate into existing projects.

README for archiver

Archiver

A streaming interface for archive generation

Visit the API documentation for a list of all methods available.

Install

npm install archiver --save

Quick Start

// require modules
const fs = require('fs');
const archiver = require('archiver');

// create a file to stream archive data to.
const output = fs.createWriteStream(__dirname + '/example.zip');
const archive = archiver('zip', {
  zlib: { level: 9 } // Sets the compression level.
});

// listen for all archive data to be written
// 'close' event is fired only when a file descriptor is involved
output.on('close', function() {
  console.log(archive.pointer() + ' total bytes');
  console.log('archiver has been finalized and the output file descriptor has closed.');
});

// This event is fired when the data source is drained no matter what was the data source.
// It is not part of this library but rather from the NodeJS Stream API.
// @see: https://nodejs.org/api/stream.html#stream_event_end
output.on('end', function() {
  console.log('Data has been drained');
});

// good practice to catch warnings (ie stat failures and other non-blocking errors)
archive.on('warning', function(err) {
  if (err.code === 'ENOENT') {
    // log warning
  } else {
    // throw error
    throw err;
  }
});

// good practice to catch this error explicitly
archive.on('error', function(err) {
  throw err;
});

// pipe archive data to the file
archive.pipe(output);

// append a file from stream
const file1 = __dirname + '/file1.txt';
archive.append(fs.createReadStream(file1), { name: 'file1.txt' });

// append a file from string
archive.append('string cheese!', { name: 'file2.txt' });

// append a file from buffer
const buffer3 = Buffer.from('buff it!');
archive.append(buffer3, { name: 'file3.txt' });

// append a file
archive.file('file1.txt', { name: 'file4.txt' });

// append files from a sub-directory and naming it `new-subdir` within the archive
archive.directory('subdir/', 'new-subdir');

// append files from a sub-directory, putting its contents at the root of archive
archive.directory('subdir/', false);

// append files from a glob pattern
archive.glob('file*.txt', {cwd:__dirname});

// finalize the archive (ie we are done appending files but streams have to finish yet)
// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand
archive.finalize();

Formats

Archiver ships with out of the box support for TAR and ZIP archives.

You can register additional formats with registerFormat.

You can check if format already exists before to register a new one with isRegisteredFormat.