extract-zip vs unzipper vs decompress vs decompress-zip
Node.js File Extraction Libraries Comparison
1 Year
extract-zipunzipperdecompressdecompress-zipSimilar Packages:
What's Node.js File Extraction Libraries?

File extraction libraries in Node.js are essential tools for developers who need to handle compressed files in various formats. These libraries provide functionality to decompress and extract files from archives, enabling seamless file management and manipulation within applications. They support different compression formats, making it easier to work with files downloaded from the internet or packaged for distribution. Choosing the right library depends on specific project requirements, such as the types of archives to be handled, performance considerations, and ease of use.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
extract-zip13,871,112392-515 years agoBSD-2-Clause
unzipper3,806,52944956.6 kB807 months agoMIT
decompress3,030,950415-435 years agoMIT
decompress-zip77,232102-284 years agoMIT
Feature Comparison: extract-zip vs unzipper vs decompress vs decompress-zip

Supported Formats

  • extract-zip:

    Exclusively handles .zip files with a straightforward API, making it easy to extract contents without additional complexity.

  • unzipper:

    Primarily focused on .zip files and streams, providing a powerful interface for both extraction and streaming of files.

  • decompress:

    Supports multiple formats including .zip, .tar, .gz, .bz2, and more, allowing for flexible file handling in various scenarios.

  • decompress-zip:

    Specifically designed for .zip files, making it a focused solution for projects that primarily deal with this format.

Ease of Use

  • extract-zip:

    Provides a very straightforward API for extracting .zip files, ideal for developers looking for a no-frills approach.

  • unzipper:

    While slightly more complex, it offers advanced features like streaming extraction, which can be beneficial for larger files.

  • decompress:

    Offers a simple and intuitive API, making it easy for developers to implement file extraction with minimal setup and configuration.

  • decompress-zip:

    Designed for simplicity, it allows quick extraction of .zip files with just a few lines of code, making it beginner-friendly.

Performance

  • extract-zip:

    Highly efficient for .zip files, focusing on performance and speed during extraction operations.

  • unzipper:

    Offers streaming capabilities which can improve performance for large .zip files, allowing for on-the-fly extraction.

  • decompress:

    Performance varies based on the format being extracted, but it is generally efficient for handling multiple formats in a single library.

  • decompress-zip:

    Optimized for .zip files, ensuring quick extraction times and minimal resource usage for this specific format.

Streaming Support

  • extract-zip:

    Does not support streaming; it is a simple extraction tool for .zip files without additional features.

  • unzipper:

    Provides robust streaming support, allowing files to be extracted directly to streams, which is useful for large files or when integrating with other stream-based processes.

  • decompress:

    Does not inherently support streaming, focusing instead on batch extraction of files from various formats.

  • decompress-zip:

    No streaming support; designed for straightforward extraction of .zip files.

Community and Maintenance

  • extract-zip:

    Maintained with a focus on .zip extraction, but may not have as large a community as more general libraries.

  • unzipper:

    Has a solid community and is actively maintained, especially for those needing advanced streaming capabilities.

  • decompress:

    Actively maintained with a growing community, ensuring ongoing support and updates for various formats.

  • decompress-zip:

    Well-maintained, but with a narrower focus on .zip files, which may limit community contributions compared to more versatile libraries.

How to Choose: extract-zip vs unzipper vs decompress vs decompress-zip
  • decompress:

    Choose 'decompress' if you need a versatile library that supports multiple archive formats (including .zip, .tar, .gz, etc.) and want a simple API for extracting files. It is ideal for projects requiring broad format support.

README for extract-zip

extract-zip

Unzip written in pure JavaScript. Extracts a zip into a directory. Available as a library or a command line program.

Uses the yauzl ZIP parser.

NPM Uses JS Standard Style Build Status

Installation

Make sure you have Node 10 or greater installed.

Get the library:

npm install extract-zip --save

Install the command line program:

npm install extract-zip -g

JS API

const extract = require('extract-zip')

async function main () {
  try {
    await extract(source, { dir: target })
    console.log('Extraction complete')
  } catch (err) {
    // handle any errors
  }
}

Options

  • dir (required) - the path to the directory where the extracted files are written
  • defaultDirMode - integer - Directory Mode (permissions), defaults to 0o755
  • defaultFileMode - integer - File Mode (permissions), defaults to 0o644
  • onEntry - function - if present, will be called with (entry, zipfile), entry is every entry from the zip file forwarded from the entry event from yauzl. zipfile is the yauzl instance

Default modes are only used if no permissions are set in the zip file.

CLI Usage

extract-zip foo.zip <targetDirectory>

If not specified, targetDirectory will default to process.cwd().