adm-zip, archiver, jszip, yazl, zip-lib, and zip-stream are JavaScript libraries for creating, reading, and manipulating ZIP archives. They differ significantly in their architecture: some are designed for in-browser use, others for Node.js; some support streaming for memory efficiency, while others load entire archives into memory; and not all support both creation and extraction. These differences make each library better suited for specific scenarios, such as serving dynamic ZIPs from a server, processing large files without memory spikes, or enabling ZIP manipulation directly in a web application.
When you need to create or extract ZIP files in a JavaScript environment β whether in Node.js or the browser β choosing the right library can make a big difference in performance, memory use, and code clarity. The six packages under review (adm-zip, archiver, jszip, yazl, zip-lib, and zip-stream) all handle ZIP operations but with very different design goals, APIs, and trade-offs. Letβs break down what each does well and where it falls short.
adm-zip: Full-featured ZIP reader/writer for Node.jsadm-zip supports both reading and writing ZIP files, including extracting entries to disk and adding files from buffers or paths. It loads the entire archive into memory, which makes it simple but unsuitable for large files.
// Read and extract
const zip = new AdmZip("./archive.zip");
zip.extractAllTo("./output/");
// Add file and write
zip.addFile("new.txt", Buffer.from("Hello"));
zip.writeZip("./updated.zip");
archiver: High-level streaming ZIP (and TAR) creatorarchiver is built on streams and excels at creating ZIPs incrementally without loading everything into memory. It supports compression, directory recursion, and piping to any writable stream (like HTTP responses). However, it cannot read or extract ZIPs.
const archive = archiver('zip');
const output = fs.createWriteStream('archive.zip');
archive.pipe(output);
archive.file('file.txt', { name: 'file.txt' });
archive.finalize();
jszip: Browser-first ZIP manipulation with limited Node supportjszip works well in browsers and can load, modify, and generate ZIPs from memory. In Node.js, it requires additional setup (e.g., using fs.promises to read files as buffers). It doesnβt support streaming and holds everything in RAM.
// Load and add
const zip = await JSZip.loadAsync(fs.readFileSync('input.zip'));
zip.file('new.txt', 'Hello');
const buffer = await zip.generateAsync({ type: 'nodebuffer' });
fs.writeFileSync('output.zip', buffer);
yazl: Low-level, streaming ZIP generator onlyyazl (Yet Another Zip Library) is a minimal, streaming-only ZIP writer. It gives fine control over entry metadata and compression but provides no extraction capability. Ideal when you need predictable memory usage and full control over the ZIP structure.
const zipfile = new yazl.ZipFile();
zipfile.addBuffer(Buffer.from('Hello'), 'hello.txt');
zipfile.end();
zipfile.outputStream.pipe(fs.createWriteStream('out.zip'));
zip-lib: Simple promise-based ZIP utility (Node.js only)zip-lib wraps lower-level libraries to offer a clean promise API for basic tasks like compressing directories or decompressing archives. Itβs easy to use but lacks advanced features like streaming or fine-grained entry control.
// Compress a folder
await zipLib.compress('./folder', './archive.zip');
// Extract
await zipLib.extract('./archive.zip', './output');
zip-stream: Barebones streaming ZIP core (used by archiver)zip-stream is the underlying engine that powers archiverβs ZIP functionality. Itβs a transform stream that converts input entries into ZIP format. You typically wonβt use it directly unless youβre building your own archiving tool.
const zip = new ZipStream();
const output = fs.createWriteStream('out.zip');
zip.pipe(output);
zip.entry('Hello', { name: 'hello.txt' }, () => {
zip.finish();
});
archiver, yazl, and zip-stream use streams and scale to large datasets. adm-zip, jszip, and zip-lib load everything into memory β avoid them for files >100MB.adm-zip, jszip, and zip-lib can extract ZIPs. If you need to read archives, rule out archiver, yazl, and zip-stream.jszip is designed for the browser. The others are Node.js-only (they rely on fs, stream, or native modules).Use archiver β it streams directly to the HTTP response without buffering.
app.get('/download', (req, res) => {
res.setHeader('Content-Type', 'application/zip');
const archive = archiver('zip');
archive.pipe(res);
archive.file('report.pdf', { name: 'report.pdf' });
archive.finalize();
});
Use jszip β it runs in the browser and handles in-memory archives cleanly.
// In browser
const arrayBuffer = await file.arrayBuffer();
const zip = await JSZip.loadAsync(arrayBuffer);
const text = await zip.file('readme.txt').async('text');
Use yazl or archiver β both stream and avoid memory spikes.
Use zip-lib β its promise API keeps your script concise.
As of 2024:
adm-zip is actively maintained but has known security issues in older versions; always use the latest release.zip-lib appears minimally maintained but still functional for basic tasks.yazl and zip-stream are low-level tools best used indirectly via archiver unless you need their specific control.| Package | Create ZIP | Extract ZIP | Streaming | Browser | Best For |
|---|---|---|---|---|---|
adm-zip | β | β | β | β | Simple Node scripts needing full read/write |
archiver | β | β | β | β | Server-side dynamic ZIP generation |
jszip | β | β | β | β | Browser-based ZIP manipulation |
yazl | β | β | β | β | Low-level, high-control ZIP writing |
zip-lib | β | β | β | β | Quick CLI zipping/unzipping |
zip-stream | β | β | β | β | Building custom archiving pipelines |
archiver β itβs robust, streaming, and well-documented.jszip is your only realistic choice.adm-zip, jszip, zip-lib) when handling user-uploaded or large files.yazl or zip-stream directly unless youβre replacing archiver for a specific reason (e.g., bundle size or custom logic).Choose based on your environment (Node vs browser), data size (small vs large), and whether you need to read, write, or both.
Choose adm-zip if you're working in a Node.js environment and need a straightforward, synchronous API for both reading and writing small ZIP files entirely in memory. Avoid it for large archives or streaming scenarios due to its memory footprint.
Choose archiver when you need to generate ZIP files dynamically in Node.js with streaming supportβideal for web servers that must pipe ZIPs directly to HTTP responses without buffering everything in memory. Note that it cannot extract or read existing ZIPs.
Choose jszip for browser-based applications where users need to upload, inspect, or download ZIP files entirely client-side. It also works in Node.js but requires manual file I/O and isn't suitable for large files due to its in-memory model.
Choose yazl only if you require fine-grained, low-level control over ZIP creation in Node.js with streaming output and want to avoid higher-level abstractions. Itβs a good fit for custom tooling but overkill for typical use cases already covered by archiver.
Choose zip-lib for simple command-line or scripting tasks in Node.js where you need a clean promise-based API to compress folders or extract archives quickly. Itβs not suitable for streaming, large files, or browser environments.
Choose zip-stream only if you're building your own archiving pipeline and need the raw streaming ZIP engine that powers archiver. For almost all practical purposes, archiver is a more complete and user-friendly alternative.
ADM-ZIP is a pure JavaScript implementation for zip data compression for NodeJS.
With npm do:
$ npm install adm-zip
Electron file system support described below.
The library allows you to:
There are no other nodeJS libraries that ADM-ZIP is dependent of
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.
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 });
.
.
.