adm-zip vs archiver vs jszip vs node-zip vs zip-a-folder vs zip-local
File Compression and Archiving
adm-ziparchiverjszipnode-zipzip-a-folderzip-localSimilar Packages:

File Compression and Archiving

File compression and archiving libraries in Node.js provide developers with tools to create, manipulate, and extract compressed files and archives, such as ZIP files. These libraries help optimize storage space, reduce file transfer times, and manage file packaging for applications. They offer various features, including streaming, encryption, and support for different compression algorithms, making them essential for tasks like file uploads, downloads, and data backup.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
adm-zip02,159121 kB1482 years agoMIT
archiver02,94743.1 kB1552 years agoMIT
jszip010,317762 kB409-(MIT OR GPL-3.0-or-later)
node-zip0217-2011 years ago-
zip-a-folder07563 kB54 months agoMIT
zip-local012157.1 kB13--

Feature Comparison: adm-zip vs archiver vs jszip vs node-zip vs zip-a-folder vs zip-local

Compression Formats

  • adm-zip:

    adm-zip supports only the ZIP format, making it a simple choice for projects that require basic ZIP compression and extraction without the need for multiple formats.

  • archiver:

    archiver supports multiple compression formats, including ZIP, TAR, and GZIP, providing greater flexibility for projects that need to work with various archive types.

  • jszip:

    jszip focuses on the ZIP format but allows for more advanced manipulation of ZIP files, including adding files, folders, and setting compression levels.

  • node-zip:

    node-zip supports only the ZIP format, making it a lightweight option for creating ZIP files without additional features.

  • zip-a-folder:

    zip-a-folder is designed specifically for zipping folders into ZIP files, providing a simple interface for directory compression.

  • zip-local:

    zip-local supports ZIP compression and extraction, offering a straightforward API for working with ZIP files.

Streaming Support

  • adm-zip:

    adm-zip does not support streaming, which means it loads entire files into memory during compression and extraction. This can be a limitation for large files or memory-intensive applications.

  • archiver:

    archiver supports streaming, allowing for efficient handling of large files and archives without consuming excessive memory. This makes it ideal for applications that need to process large data streams.

  • jszip:

    jszip does not natively support streaming, as it is designed for in-memory manipulation of ZIP files. However, it can be integrated with streaming APIs for more advanced use cases.

  • node-zip:

    node-zip does not support streaming, which limits its ability to handle large files efficiently. It is best suited for small to medium-sized files.

  • zip-a-folder:

    zip-a-folder does not provide streaming capabilities, as it focuses on simple folder compression. It may not be suitable for very large directories or memory-sensitive applications.

  • zip-local:

    zip-local does not support streaming, which means it processes files in memory during compression and extraction. This can be a limitation for large files.

Encryption and Password Protection

  • adm-zip:

    adm-zip does not support encryption or password protection, making it unsuitable for projects that require secure ZIP files.

  • archiver:

    archiver does not have built-in support for encryption, but it allows for customization and integration with other libraries to add encryption features.

  • jszip:

    jszip does not support encryption or password protection natively. However, there are third-party plugins and libraries that can be integrated to add these features.

  • node-zip:

    node-zip does not support encryption or password protection, limiting its use for secure file compression.

  • zip-a-folder:

    zip-a-folder does not provide encryption or password protection features, as it focuses on simple folder compression.

  • zip-local:

    zip-local does not support encryption or password protection, making it a basic tool for ZIP file manipulation without security features.

Folder Compression

  • adm-zip:

    adm-zip allows for folder compression by adding directories and their contents to a ZIP archive. However, it requires manual handling of folder structures and does not provide a dedicated method for zipping entire folders.

  • archiver:

    archiver provides robust support for folder compression, allowing developers to easily add entire directories to an archive with a single command. It is highly efficient and supports streaming, making it suitable for large folders.

  • jszip:

    jszip supports folder compression by allowing the creation of nested folder structures within a ZIP file. However, it is primarily designed for in-memory operations and may not be as efficient for large directories compared to streaming-based solutions.

  • node-zip:

    node-zip allows for folder compression by adding files and directories to a ZIP archive. However, it lacks advanced features and may require additional code to handle complex folder structures.

  • zip-a-folder:

    zip-a-folder is specifically designed for folder compression, providing a simple and intuitive API for zipping entire directories with minimal code. It is efficient and easy to use for quick folder compression tasks.

  • zip-local:

    zip-local supports folder compression by allowing users to zip entire directories with a simple API. It is user-friendly and suitable for both small and large folders.

Ease of Use: Code Examples

  • adm-zip:

    Simple ZIP Creation and Extraction

    const AdmZip = require('adm-zip');
    const zip = new AdmZip();
    
    // Add a file to the ZIP
    zip.addLocalFile('path/to/file.txt');
    
    // Add a folder to the ZIP
    zip.addLocalFolder('path/to/folder');
    
    // Save the ZIP file
    zip.writeZip('output.zip');
    
    // Extract the ZIP file
    const zipToExtract = new AdmZip('output.zip');
    zipToExtract.extractAllTo('extracted_folder', true);
    
  • archiver:

    Streaming ZIP Creation with Multiple Formats

    const fs = require('fs');
    const archiver = require('archiver');
    
    const output = fs.createWriteStream('output.zip');
    const archive = archiver('zip', {
      zlib: { level: 9 } // Compression level
    });
    
    output.on('close', () => {
      console.log(`Archive created with ${archive.pointer()} total bytes`);
    });
    
    archive.on('error', (err) => {
      throw err;
    });
    
    archive.pipe(output);
    
    // Add files and folders
    archive.file('path/to/file.txt', { name: 'file.txt' });
    archive.directory('path/to/folder', 'folder');
    
    archive.finalize();
    
  • jszip:

    In-Memory ZIP Creation and Extraction

    const JSZip = require('jszip');
    const fs = require('fs');
    const zip = new JSZip();
    
    // Add files and folders
    zip.file('file.txt', 'Hello, World!');
    const folder = zip.folder('folder');
    folder.file('nested.txt', 'Nested file content');
    
    // Generate ZIP file
    zip.generateAsync({ type: 'nodebuffer' }).then((content) => {
      fs.writeFileSync('output.zip', content);
    });
    
    // Extract ZIP file (example using jszip)
    fs.readFile('output.zip', (err, data) => {
      if (err) throw err;
      JSZip.loadAsync(data).then((zip) => {
        zip.file('file.txt').async('string').then((text) => {
          console.log('Extracted content:', text);
        });
      });
    });
    
  • node-zip:

    Basic ZIP Creation

    const NodeZip = require('node-zip');
    const fs = require('fs');
    const zip = new NodeZip();
    
    // Add files to the ZIP
    zip.file('file.txt', 'Hello, World!');
    
    // Generate ZIP data
    const data = zip.generate({ base64: false, compression: 'DEFLATE' });
    
    // Save ZIP file
    fs.writeFileSync('output.zip', data, 'binary');
    
  • zip-a-folder:

    Simple Folder Zipping

    const { zip } = require('zip-a-folder');
    
    zip('path/to/folder', 'output.zip')
      .then(() => {
        console.log('Folder zipped successfully');
      })
      .catch((err) => {
        console.error('Error zipping folder:', err);
      });
    
  • zip-local:

    Easy ZIP and Unzip

    const { zip, unzip } = require('zip-local');
    
    // Zip a folder
    zip('path/to/folder').compress().save('output.zip');
    
    // Unzip a file
    unzip('output.zip').extract('extracted_folder');
    

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

  • adm-zip:

    Choose adm-zip if you need a simple and straightforward solution for creating and extracting ZIP files with minimal configuration. It is ideal for projects that require basic ZIP functionality without the need for advanced features.

  • archiver:

    Choose archiver if you need a more powerful and flexible solution for creating archives, including support for multiple formats (ZIP, TAR, etc.). It is suitable for applications that require streaming capabilities and more control over the archiving process.

  • jszip:

    Choose jszip if you need a library that works both in Node.js and the browser for creating and manipulating ZIP files. It is great for applications that require client-side zipping and unzipping, as well as server-side functionality.

  • node-zip:

    Choose node-zip if you need a lightweight library for creating ZIP files with a simple API. It is suitable for projects that require basic ZIP creation without additional features or complexity.

  • zip-a-folder:

    Choose zip-a-folder if you need a straightforward way to zip entire folders with minimal code. It is ideal for applications that need to compress directories quickly and easily without dealing with low-level ZIP operations.

  • zip-local:

    Choose zip-local if you need a simple and intuitive API for zipping and unzipping files and folders. It is suitable for projects that require easy-to-use compression and extraction functionality with minimal setup.

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 });
.
.
.