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

These libraries provide functionality for creating, reading, and manipulating ZIP files in Node.js applications. They allow developers to easily compress files and directories into ZIP format, extract files from ZIP archives, and manage the contents of ZIP files programmatically. Each library has its own strengths and use cases, catering to different needs in terms of performance, ease of use, and features.

NPM Package Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
archiver10,139,1042,83343.1 kB1499 months agoMIT
jszip9,077,0729,836762 kB419-(MIT OR GPL-3.0-or-later)
adm-zip5,707,7762,064121 kB1393 months agoMIT
zip-a-folder196,72271107 kB0a month agoMIT
node-zip85,874217-2010 years ago-
zip-local22,46212057.1 kB13-
Feature Comparison: archiver vs jszip vs adm-zip vs zip-a-folder vs node-zip vs zip-local

Ease of Use

  • archiver:

    archiver provides a more complex API but offers extensive documentation and examples, making it accessible for developers willing to invest time in learning its features. It supports various formats beyond ZIP, enhancing its usability.

  • jszip:

    jszip is user-friendly and offers a clear API for creating and manipulating ZIP files. It is particularly beneficial for developers familiar with JavaScript, as it uses familiar constructs and patterns.

  • adm-zip:

    adm-zip is designed for simplicity, making it easy for developers to quickly read and write ZIP files with minimal setup. Its straightforward API allows for rapid implementation without deep knowledge of ZIP file structures.

  • zip-a-folder:

    zip-a-folder is extremely user-friendly, allowing developers to zip entire folders with a single function call. It abstracts away the complexities of file handling, making it ideal for quick implementations.

  • node-zip:

    node-zip is lightweight and easy to use, focusing on basic functionalities without unnecessary complexity. It is suitable for quick tasks where ease of implementation is a priority.

  • zip-local:

    zip-local is designed for straightforward usage, enabling developers to zip and unzip files with simple commands. Its focus on local file operations makes it intuitive for basic tasks.

Performance

  • archiver:

    archiver excels in performance, especially with large files and streaming data. It uses a streaming approach that minimizes memory usage, making it suitable for applications that need to handle large amounts of data efficiently.

  • jszip:

    jszip performs well for moderate-sized files but may experience slower performance with very large files due to its in-memory operations. It is best suited for applications where file size is manageable.

  • adm-zip:

    adm-zip is efficient for small to medium-sized ZIP files but may not perform optimally with very large files due to its in-memory processing approach. It is best used for tasks that do not require handling massive datasets.

  • zip-a-folder:

    zip-a-folder is optimized for zipping folders quickly, making it efficient for directory structures. Its performance is generally good for typical use cases involving folder compression.

  • node-zip:

    node-zip is lightweight and performs adequately for basic tasks, but it may not be the best choice for performance-critical applications that require handling large ZIP files.

  • zip-local:

    zip-local is designed for local operations and performs well for basic zipping tasks. However, it may not be optimized for handling very large files or complex directory structures.

Streaming Support

  • archiver:

    archiver provides robust streaming support, allowing developers to create ZIP files on-the-fly. This is particularly useful for applications that need to generate ZIP files from data streams, such as web applications serving downloads.

  • jszip:

    jszip does not offer streaming capabilities, focusing instead on in-memory operations. This makes it less suitable for large files that would benefit from a streaming approach.

  • adm-zip:

    adm-zip does not support streaming, as it processes files in memory. This can lead to high memory consumption when dealing with large files or multiple files at once.

  • zip-a-folder:

    zip-a-folder does not support streaming, as it is designed for straightforward folder zipping. It is best for smaller projects where streaming is not a concern.

  • node-zip:

    node-zip lacks streaming support, which can limit its effectiveness for applications that require efficient handling of large datasets or real-time file processing.

  • zip-local:

    zip-local does not provide streaming capabilities, focusing instead on local file operations. It is suitable for simple use cases but may not handle large files efficiently.

File Format Support

  • archiver:

    archiver supports multiple formats, including ZIP, TAR, and GZIP, making it a versatile choice for applications that require various compression formats. This flexibility allows developers to choose the best format for their needs.

  • jszip:

    jszip is dedicated to the ZIP format, providing extensive capabilities for creating and manipulating ZIP files. It does not support other formats, which may limit its use in applications requiring diverse file handling.

  • adm-zip:

    adm-zip primarily focuses on ZIP file format, providing comprehensive support for reading and writing ZIP files. It does not extend to other compression formats, limiting its versatility.

  • zip-a-folder:

    zip-a-folder is specifically designed for zipping folders into the ZIP format, making it easy to compress directory structures without additional format support.

  • node-zip:

    node-zip is focused on ZIP file creation and extraction, providing basic support for the ZIP format without extending to other compression types. It is suitable for simple ZIP file tasks.

  • zip-local:

    zip-local is tailored for the ZIP format, providing basic functionality for zipping and unzipping files. It does not support other compression formats.

Use Cases

  • archiver:

    archiver is well-suited for applications that need to generate ZIP files dynamically, such as web applications that serve downloadable content or need to archive data on-the-fly.

  • jszip:

    jszip is perfect for web applications that require ZIP file manipulation in the browser, allowing for client-side file handling and compression without server interaction.

  • adm-zip:

    adm-zip is ideal for applications that require simple ZIP file manipulation, such as file uploads or downloads, where ease of use and quick implementation are priorities.

  • zip-a-folder:

    zip-a-folder is specifically designed for zipping entire folders, making it ideal for applications that need to package directory structures quickly and easily.

  • node-zip:

    node-zip is best for lightweight applications that need basic ZIP file creation and extraction without extensive features or overhead.

  • zip-local:

    zip-local is suitable for local applications that require basic ZIP functionality, such as desktop utilities for file management.

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

    Select archiver if you require advanced features such as streaming support and the ability to create ZIP files on-the-fly. It is ideal for applications that need to handle large files or directories efficiently.

  • jszip:

    Opt for jszip if you need a pure JavaScript solution that works in both Node.js and the browser. It is great for applications that require ZIP file manipulation in client-side code or need compatibility across environments.

  • adm-zip:

    Choose adm-zip if you need a straightforward and easy-to-use library for basic ZIP file operations. It is suitable for simple tasks like reading and writing ZIP files without complex features.

  • zip-a-folder:

    Choose zip-a-folder if you specifically need to zip entire folders easily. This library simplifies the process of zipping directories without requiring extensive configuration or setup.

  • node-zip:

    Use node-zip if you want a lightweight library for basic ZIP file creation and extraction. It is simple and effective for quick tasks without the overhead of more complex libraries.

  • zip-local:

    Select zip-local for local file zipping and unzipping operations in a straightforward manner. It is designed for ease of use and is suitable for applications that need basic ZIP functionality.

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.