archiver vs jszip vs pizzip
JavaScript Zip Libraries Comparison
1 Year
archiverjszippizzipSimilar Packages:
What's JavaScript Zip Libraries?

JavaScript zip libraries are essential tools for handling compressed file formats in web applications. They allow developers to create, read, and manipulate zip files directly in the browser or on the server side. These libraries are particularly useful for applications that require file downloads, uploads, or packaging multiple files into a single compressed format for easier transfer and storage. Each library comes with its own set of features, performance characteristics, and use cases, making it important for developers to choose the right one based on their specific needs.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
archiver11,655,8752,86343.1 kB150a year agoMIT
jszip10,249,8719,977762 kB402-(MIT OR GPL-3.0-or-later)
pizzip132,26550575 kB03 months ago(MIT OR GPL-3.0)
Feature Comparison: archiver vs jszip vs pizzip

File Handling

  • archiver:

    Archiver excels in handling large files and directories, allowing for efficient streaming of data to zip files. It supports multiple compression formats and can handle complex file structures, making it suitable for server-side applications.

  • jszip:

    JSZip provides a straightforward API for creating and reading zip files directly in the browser. It supports adding files, folders, and even binary data, making it versatile for client-side file manipulations.

  • pizzip:

    PizZip is designed for simplicity and focuses on working with zip files containing document templates. It allows for easy manipulation of zip files, particularly for generating and modifying documents.

Performance

  • archiver:

    Archiver is optimized for performance on the server side, utilizing streams to handle large files without consuming excessive memory. This makes it ideal for applications that need to generate zip files on-the-fly without performance degradation.

  • jszip:

    JSZip is efficient for smaller files and works well in the browser, but performance may vary with larger files due to memory constraints. It is best used for applications where file sizes are manageable and user experience is prioritized.

  • pizzip:

    PizZip is lightweight and performs well with document templates, but it may not be as efficient as Archiver for handling large datasets. It is best suited for applications focused on document generation rather than bulk file processing.

Ease of Use

  • archiver:

    Archiver has a steeper learning curve due to its extensive features and server-side focus. However, its comprehensive documentation helps developers quickly understand its capabilities for file handling.

  • jszip:

    JSZip is known for its user-friendly API, making it easy for developers to get started with zip file creation and manipulation in the browser. Its simplicity is a key advantage for client-side applications.

  • pizzip:

    PizZip offers a very simple API, especially when used in conjunction with libraries like Docxtemplater. This makes it easy to integrate into applications that require document manipulation.

Use Cases

  • archiver:

    Archiver is ideal for server-side applications that need to create zip files from various sources, such as user uploads or database exports. It is commonly used in backend services where file generation is required.

  • jszip:

    JSZip is perfect for client-side applications that require users to download multiple files as a zip. It is often used in web applications that allow users to select files for download, packaging them into a single zip file.

  • pizzip:

    PizZip is best suited for applications focused on document generation, particularly when working with templates. It is commonly used in scenarios where documents need to be created or modified on the fly.

Community and Support

  • archiver:

    Archiver has a strong community and is widely used in Node.js applications, ensuring good support and regular updates. Its popularity means that developers can find ample resources and examples online.

  • jszip:

    JSZip has a large user base and is actively maintained, providing a wealth of resources and community support. This makes it a reliable choice for client-side zip file handling.

  • pizzip:

    PizZip, while not as widely known as the others, has a dedicated user community, particularly among those using it for document generation. Its integration with other libraries enhances its usability.

How to Choose: archiver vs jszip vs pizzip
  • archiver:

    Choose Archiver if you need a robust solution for creating zip files on the server side with Node.js. It supports streaming and can handle large files efficiently, making it ideal for applications that generate zip files dynamically.

  • jszip:

    Select JSZip for client-side applications where you need to create or read zip files in the browser. It offers a simple API and is well-suited for applications that require user interaction with zip files, such as downloading multiple files as a single zip.

  • pizzip:

    Opt for PizZip if you are looking for a lightweight library that works well with other libraries like Docxtemplater for generating documents. It is particularly useful for applications that need to manipulate zip files containing document templates.

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.