JavaScript compression libraries

Updated Nov 2026

JavaScript compression libraries shrink bytes and strings with formats such as gzip, DEFLATE, and Brotli. An archive format such as ZIP or tar bundles many files into one container with each file compressed inside it. These libraries reduce the size of API responses, file exports, and values kept in browser storage.

Popularity

pako has the most monthly downloads in this comparison, at 714.9M.

LibraryMonthly downloadsStarsLast releaseLicense
pako
714.9M
6.1KOct 2026(MIT AND Zlib)
fflate
591.7M
3.1KMay 2026MIT
tar
459.8M
925Nov 2026BlueOak-1.0.0
lz-string
414.8M
4.4KMar 2023MIT
yauzl
277.5M
832Jun 2026MIT
JSZip
274.1M
10.4KSep 2026(MIT OR GPL-3.0-or-later)
archiver
261.9M
3.0KMay 2026MIT
compression
238.9M
2.8KSep 2026MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryZIP creationGzip compressionBrowser byte API
pakoUnsupportedBuilt-inBuilt-in
fflateBuilt-inBuilt-inBuilt-in
tarUnsupportedBuilt-inUnsupported
lz-stringUnsupportedUnsupportedBuilt-in
yauzlUnsupportedUnsupportedUnsupported
JSZipBuilt-inUnsupportedBuilt-in
archiverBuilt-inBuilt-inUnsupported
compressionUnsupportedBuilt-inUnsupported
Built-inNot supported

Libraries and code examples

Provides zlib-compatible compression and decompression in JavaScript.

Downloads / mo
714.9M
Stars
6.1K
Last release
3.0.3
License
(MIT AND Zlib)

Strengths

  • Compresses JavaScript strings directly. String input is encoded as UTF-8 before compression.
  • Processes data in chunks. Push incoming chunks through Deflate or Inflate.

Limitations

  • Cannot retune a running deflator. Choose settings before starting; deflateParams is unavailable.

Quickstart

From pako docs
$ npm install pako
import { deflate } from 'pako';

const compressed = deflate('Hello world!');

pako examples

From open-source projects on GitHub
protected toEprops(params:unknown):{ eprops:string } {
  const deflatedArray = Pako.deflate(JSON.stringify(params));

  const compressed = base64.bytesToBase64(deflatedArray);

  return { eprops: compressed };
}

Compresses and decompresses DEFLATE, gzip and zlib data with optional ZIP archiving.

Downloads / mo
591.7M
Stars
3.1K
Last release
0.8.3
License
MIT

Strengths

  • Offloads asynchronous work to workers. Use callback APIs to avoid blocking the main thread.
  • Streams multi-file ZIP archives. Add file streams before pushing their data.

Limitations

  • Async calls pay startup overhead. Prefer synchronous APIs for small payloads.
  • Consumed input buffers become unusable. Copy data before enabling consume when it must be reused.

Quickstart

From README.md
$ npm install fflate
import { strToU8, gzipSync } from 'fflate';

const compressed = gzipSync(strToU8('Hello world!'));

fflate examples

From open-source projects on GitHub

Creates and extracts tar archives in Node.js with an API modeled on the Unix tar command.

Downloads / mo
459.8M
Stars
925
Last release
7.5.23
License
BlueOak-1.0.0

Strengths

  • Blocks paths outside the target. Extraction ignores entries that walk up outside the target folder.

Quickstart

From README.md
$ npm install tar
import { create } from 'tar';

await create({ gzip: true, file: 'archive.tgz' }, ['hello.txt']);

tar examples

From open-source projects on GitHub

Compresses JavaScript strings for storage and URL-safe transport.

Downloads / mo
414.8M
Stars
4.4K
Last release
1.5.0
License
MIT

Strengths

  • Targets string-based browser storage. Use compressToUTF16 for UTF-16-safe stored strings.
  • Builds URI-safe compressed values. Use compressToEncodedURIComponent when compressed data belongs in URLs.

Limitations

  • Raw output is invalid UTF-16. Use compressToUTF16 when storage requires valid text.
  • Cross-language ports can differ. Verify matching encoded bytes before exchanging data with server-side ports.

Quickstart

From guide.html
$ npm install lz-string
const LZString = require('lz-string');

const compressed = LZString.compressToUTF16('Hello world!');

lz-string examples

From open-source projects on GitHub
function compress(input: string) {
    return LZString.compressToBase64(input)
        .replace(/\+/g, `-`) // Convert '+' to '-'
        .replace(/\//g, `_`) // Convert '/' to '_'
        .replace(/=+$/, ``); // Remove ending '='
}

Reads ZIP files in Node.js from the central directory that holds each file's metadata.

Downloads / mo
277.5M
Stars
832
Last release
3.4.0
License
MIT

Strengths

  • Never buffers whole files. Entries stream out without loading whole files into memory.

Limitations

  • Reads only. Create ZIP files with the companion package yazl.
  • No streaming unzip. Open a file or a buffer rather than a readable stream.

Quickstart

From README.md
$ npm install yauzl
const yauzl = require('yauzl');

yauzl.open('archive.zip', { lazyEntries: true }, (err, zipfile) => {
  if (err) throw err;
  zipfile.close();
});

yauzl examples

From open-source projects on GitHub

Creates, reads, and edits ZIP files from JavaScript.

Downloads / mo
274.1M
Stars
10.4K
Last release
3.10.2
License
(MIT OR GPL-3.0-or-later)

Strengths

  • Sets compression per file. Each file in the archive can set its own DEFLATE compression level.

Limitations

  • Dual license. Choose the MIT license or GPLv3 when using it.

Quickstart

From index.d.ts
$ npm install jszip
const JSZip = require('jszip');

const zip = new JSZip();
zip.file('hello.txt', 'Hello world!');
const compressedZipPromise = zip.generateAsync({ type: 'uint8array', compression: 'DEFLATE' });

JSZip examples

From open-source projects on GitHub

Generates archives through a streaming interface.

Downloads / mo
261.9M
Stars
3.0K
Last release
8.0.0
License
MIT

Strengths

  • Sets the compression level. The zlib option sets the compression level of a ZIP archive.

Limitations

  • Needs error handlers. Listen for warning and error events on the archive.

Quickstart

From README.md
$ npm install archiver
import fs from 'node:fs';
import { ZipArchive } from 'archiver';

const output = fs.createWriteStream('archive.zip');
const archive = new ZipArchive();
output.on('error', console.error);
archive.on('error', console.error);
archive.pipe(output);
archive.append('Hello world!', { name: 'hello.txt' });
await archive.finalize();

archiver examples

From open-source projects on GitHub

Compresses HTTP response bodies in Node.js with deflate, gzip, or Brotli.

Downloads / mo
238.9M
Stars
2.8K
Last release
1.8.2
License
MIT

Strengths

  • Accepts zlib options. zlib and Brotli settings pass through the options object.

Limitations

  • Skips no-transform responses. Responses with a Cache-Control no-transform header go out uncompressed.

Quickstart

From README.md
$ npm install compression express
const express = require('express');
const compression = require('compression');

const app = express();
app.use(compression());
app.get('/', (_req, res) => res.send('Hello world!'.repeat(1000)));
app.listen(3000);

compression examples

From open-source projects on GitHub

FAQ

JSZip creates, reads, and edits ZIP files from JavaScript. Each file in the archive can set its own DEFLATE compression level.

lz-string compresses JavaScript strings for browser storage and URLs. Use compressToUTF16 for UTF-16-safe stored strings.

pako and fflate compress bytes and strings to gzip in the browser and in Node.js. In an Express server, the compression middleware gzips response bodies instead.

tar creates and extracts tar archives in Node.js with an API modeled on the Unix tar command.

fflate warns about worker startup overhead and slower async APIs on small payloads.

Its own missing-function list includes deflateParams; choose required settings before starting the stream.

For coding agents

Found your compression library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official