# JavaScript compression libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [pako](#pako) | 714.9M | 6.1K | Oct 2026 | (MIT AND Zlib) |
| [fflate](#fflate) | 591.7M | 3.1K | May 2026 | MIT |
| [tar](#tar) | 459.8M | 925 | Nov 2026 | BlueOak-1.0.0 |
| [lz-string](#lz-string) | 414.8M | 4.4K | Mar 2023 | MIT |
| [yauzl](#yauzl) | 277.5M | 832 | Jun 2026 | MIT |
| [JSZip](#jszip) | 274.1M | 10.4K | Sep 2026 | (MIT OR GPL-3.0-or-later) |
| [archiver](#archiver) | 261.9M | 3.0K | May 2026 | MIT |
| [compression](#compression) | 238.9M | 2.8K | Sep 2026 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[pako](#pako) has the most monthly downloads in this comparison, at 714.9M.

## Capabilities

| Library | ZIP creation | Gzip compression | Browser byte API |
| --- | --- | --- | --- |
| [pako](#pako) | No | Yes | Yes |
| [fflate](#fflate) | Yes | Yes | Yes |
| [tar](#tar) | No | Yes | No |
| [lz-string](#lz-string) | No | No | Yes |
| [yauzl](#yauzl) | No | No | No |
| [JSZip](#jszip) | Yes | No | Yes |
| [archiver](#archiver) | Yes | Yes | No |
| [compression](#compression) | No | Yes | No |

## Libraries

### pako

[GitHub](https://github.com/nodeca/pako) · [npm](https://www.npmjs.com/package/pako) · [Docs](https://nodeca.github.io/pako/)

Provides zlib-compatible compression and decompression in JavaScript.

- Downloads / mo: 714.9M
- Stars: 6.1K
- Last release: 3.0.3
- License: (MIT AND Zlib)
- Capabilities: [From the pako docs](https://nodeca.github.io/pako/)

**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.

**Watch out for**

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

```sh
npm install pako
```

**opf/openproject** (17.5K stars)

[opf/openproject](https://github.com/opf/openproject) 

```typescript
protected toEprops(params:unknown):{ eprops:string } {
  const deflatedArray = Pako.deflate(JSON.stringify(params));

  const compressed = base64.bytesToBase64(deflatedArray);

  return { eprops: compressed };
}

```

[frontend/src/app/features/hal/services/hal-resource.service.ts](https://github.com/opf/openproject/blob/8c1a979057b8e1da86d4aabe1587a548d3bd54b4/frontend/src/app/features/hal/services/hal-resource.service.ts#L311-L317) · [More projects using pako →](https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20pako%20to%20compress%20browser%20storage%2C%20stream%20archive%20entries%20or%20decode%20compressed%20payloads&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import { deflate } from 'pako';

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

```

From [pako docs](https://nodeca.github.io/pako/)

### fflate

[GitHub](https://github.com/101arrowz/fflate) · [npm](https://www.npmjs.com/package/fflate) · [Docs](https://github.com/101arrowz/fflate/blob/dcb3714a6c25db3a2748641019c5277413d09714/README.md)

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
- Capabilities: [From the fflate docs](https://github.com/101arrowz/fflate/blob/dcb3714a6c25db3a2748641019c5277413d09714/README.md)

**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.

**Watch out for**

- **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.

```sh
npm install fflate
```

**angular/angular** (101.5K stars)

[angular/angular](https://github.com/angular/angular) 

```typescript
export async function generateZip(files: FileAndContent[]): Promise<Uint8Array> {
  if (zip === undefined || strToU8 === undefined) {
    const fflate = require('fflate');
    zip = fflate.zip;
    strToU8 = fflate.strToU8;
  }
  const filesObj: Record<string, Uint8Array> = {};
  files.forEach(({path, content}) => {
    filesObj[path] = typeof content === 'string' ? strToU8(content) : content;
  });

  return new Promise((resolve, reject) => {
    zip(filesObj, (err: any, data: any) => {
      if (err) {
        reject(err);
      } else {
        resolve(data);
      }
    });
  });
}

```

[adev/shared-docs/utils/zip.utils.ts](https://github.com/angular/angular/blob/ca92b968b8ec43ec2037302ac5e1104948aea924/adev/shared-docs/utils/zip.utils.ts#L16-L36) · [More projects using fflate →](https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20fflate%20to%20compress%20browser%20storage%2C%20stream%20archive%20entries%20or%20decode%20compressed%20payloads&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import { strToU8, gzipSync } from 'fflate';

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

```

From [README.md](https://github.com/101arrowz/fflate/blob/dcb3714a6c25db3a2748641019c5277413d09714/README.md)

### tar

[GitHub](https://github.com/isaacs/node-tar) · [npm](https://www.npmjs.com/package/tar) · [Docs](https://github.com/isaacs/node-tar/blob/main/README.md)

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
- Capabilities: [From the tar docs](https://github.com/isaacs/node-tar/blob/main/README.md)

**Strengths**

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

```sh
npm install tar
```

**microsoft/vscode** (195.5K stars)

[microsoft/vscode](https://github.com/microsoft/vscode) 

```javascript
async function buildTarball(stagingDir: string, outTgz: string): Promise<void> {
	await tar.c(
		{
			file: outTgz,
			cwd: stagingDir,
			gzip: { level: 9 },
			portable: true,
			mtime: new Date(0),
		},
		['prebuilds'],
	);
}

```

[build/dictation-runtime/package.ts](https://github.com/microsoft/vscode/blob/9b61e7d80599cef2f14c6f3b1c286a9f611686db/build/dictation-runtime/package.ts#L142-L153) · [More projects using tar →](https://dashboard.exa.ai/playground/search?q=tar%20GitHub%20projects)

**Quickstart**

```javascript
import { create } from 'tar';

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

```

From [README.md](https://github.com/isaacs/node-tar/blob/main/README.md)

### lz-string

[GitHub](https://github.com/pieroxy/lz-string) · [npm](https://www.npmjs.com/package/lz-string) · [Docs](https://pieroxy.net/blog/pages/lz-string/index.html)

Compresses JavaScript strings for storage and URL-safe transport.

- Downloads / mo: 414.8M
- Stars: 4.4K
- Last release: 1.5.0
- License: MIT
- Capabilities: [From the lz-string docs](https://pieroxy.net/blog/pages/lz-string/index.html)

**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.

**Watch out for**

- **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.

```sh
npm install lz-string
```

**palantir/blueprint** (22.2K stars)

[palantir/blueprint](https://github.com/palantir/blueprint) 

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

```

[packages/docs-theme/src/common/sandbox.ts](https://github.com/palantir/blueprint/blob/47852d7ad3b1346b1fe24095f80566477629d269/packages/docs-theme/src/common/sandbox.ts#L16-L21) · [More projects using lz-string →](https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20lz-string%20to%20compress%20browser%20storage%2C%20stream%20archive%20entries%20or%20decode%20compressed%20payloads&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
const LZString = require('lz-string');

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

```

From [guide.html](https://pieroxy.net/blog/pages/lz-string/guide.html)

### yauzl

[GitHub](https://github.com/thejoshwolfe/yauzl) · [npm](https://www.npmjs.com/package/yauzl) · [Docs](https://github.com/thejoshwolfe/yauzl/blob/master/README.md)

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
- Capabilities: [From the yauzl docs](https://github.com/thejoshwolfe/yauzl/blob/master/README.md)

**Strengths**

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

**Watch out for**

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

```sh
npm install yauzl
```

**overleaf/overleaf** (18.3K stars)

[overleaf/overleaf](https://github.com/overleaf/overleaf) 

```javascript
function _extractZipFiles(source, destination) {
  return new Promise((resolve, reject) => {
    let settled = false
    const done = err => {
      if (settled) return
      settled = true
      if (err) reject(err)
      else resolve()
    }

    yauzl.open(source, { lazyEntries: true }, (err, zipfile) => {
      if (err) return done(err)

      zipfile.on('error', err => done(err))
      // read all the entries
      zipfile.readEntry()

      let entryFileCount = 0
      zipfile.on('entry', entry => {
        if (FileTypeManager.shouldIgnore(entry.fileName)) {
          return zipfile.readEntry()
        }

        let destFile
        try {
          destFile = _checkFilePath(entry, destination)
        } catch (err) {
          logger.warn({ err, source, destination }, 'skipping bad file path')
          zipfile.readEntry() // bad path, just skip to the next file
          return
        }
        if (destFile) {
          // only write files
          _writeFileEntry(zipfile, entry, destFile, err => {
            if (err) {
              OError.tag(err, 'error unzipping file entry', {
                source,
                destFile,
              })
              zipfile.close() // bail out, stop reading file entries
              done(new InvalidZipFileError().withCause(err))
            } else {
              entryFileCount++
              zipfile.readEntry() // continue to the next file
            }
          })
        } else {
          // if it's a directory, continue
          zipfile.readEntry()
        }
      })

      // no more entries to read
      zipfile.on('end', () => {
        if (entryFileCount > 0) {
          done()
        } else {
          done(new EmptyZipFileError())
        }
      })
    })
  })
}

```

[services/web/app/src/Features/Uploads/ArchiveManager.mjs](https://github.com/overleaf/overleaf/blob/e039ad26c5bf5422eb57b89fc7e57c75055e631d/services/web/app/src/Features/Uploads/ArchiveManager.mjs#L127-L189) · [More projects using yauzl →](https://dashboard.exa.ai/playground/search?q=yauzl%20GitHub%20projects)

**Quickstart**

```javascript
const yauzl = require('yauzl');

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

```

From [README.md](https://github.com/thejoshwolfe/yauzl/blob/master/README.md)

### JSZip

[GitHub](https://github.com/Stuk/jszip) · [npm](https://www.npmjs.com/package/jszip) · [Docs](https://github.com/Stuk/jszip/blob/main/index.d.ts)

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)
- Capabilities: [From the JSZip docs](https://github.com/Stuk/jszip/blob/main/index.d.ts)

**Strengths**

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

**Watch out for**

- **Dual license.** Choose the MIT license or GPLv3 when using it.

```sh
npm install jszip
```

**dolanmiu/docx** (6.0K stars)

[dolanmiu/docx](https://github.com/dolanmiu/docx) 

```javascript
public static async pack<T extends OutputType>(
    file: File,
    type: T,
    prettify?: boolean | (typeof PrettifyType)[keyof typeof PrettifyType],
    overrides: readonly IXmlifyedFile[] = [],
): Promise<OutputByType[T]> {
    const zip = this.compiler.compile(file, convertPrettifyType(prettify), overrides);
    return zip.generateAsync({
        type,
        mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
        compression: "DEFLATE",
    });
}

```

[src/export/packer/packer.ts](https://github.com/dolanmiu/docx/blob/f73676fb9dab425edd8614fecfe7270ee2b9c876/src/export/packer/packer.ts#L26-L38) · [More projects using JSZip →](https://dashboard.exa.ai/playground/search?q=jszip%20GitHub%20projects)

**Quickstart**

```javascript
const JSZip = require('jszip');

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

```

From [index.d.ts](https://github.com/Stuk/jszip/blob/main/index.d.ts)

### archiver

[GitHub](https://github.com/archiverjs/node-archiver) · [npm](https://www.npmjs.com/package/archiver) · [Docs](https://github.com/archiverjs/node-archiver/blob/master/README.md)

Generates archives through a streaming interface.

- Downloads / mo: 261.9M
- Stars: 3.0K
- Last release: 8.0.0
- License: MIT
- Capabilities: [From the archiver docs](https://github.com/archiverjs/node-archiver/blob/master/README.md)

**Strengths**

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

**Watch out for**

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

```sh
npm install archiver
```

**TriliumNext/Trilium** (39.0K stars)

[TriliumNext/Trilium](https://github.com/TriliumNext/Trilium) 

```javascript
append(content: string | Uint8Array, options: ZipArchiveEntryOptions) {
    if (this.#error) {
        throw this.#error;
    }
    // A Buffer view over the same memory rather than a copy; archiver only reads, so sharing is safe.
    const payload = typeof content === "string" ? content : asBuffer(content);
    const size = typeof content === "string" ? Buffer.byteLength(content) : content.byteLength;
    this.#pendingSizes.push(size);
    this.#queuedBytes += size;
    // `store` (and `date`) pass straight through: archiver preserves extra
    // entry-data fields and zip-stream switches to the STORE method when set.
    this.#archive.append(payload, options);
}

```

[apps/server/src/zip_provider.ts](https://github.com/TriliumNext/Trilium/blob/3c60eac13f66161492334efefa2613923ebe541f/apps/server/src/zip_provider.ts#L60-L72) · [More projects using archiver →](https://dashboard.exa.ai/playground/search?q=archiver%20GitHub%20projects)

**Quickstart**

```javascript
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();

```

From [README.md](https://github.com/archiverjs/node-archiver/blob/master/README.md)

### compression

[GitHub](https://github.com/expressjs/compression) · [npm](https://www.npmjs.com/package/compression) · [Docs](https://github.com/expressjs/compression/blob/master/README.md)

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
- Capabilities: [From the compression docs](https://github.com/expressjs/compression/blob/master/README.md)

**Strengths**

- **Accepts zlib options.** zlib and Brotli settings pass through the options object.

**Watch out for**

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

```sh
npm install compression express
```

**ember-cli/ember-cli** (3.2K stars)

[ember-cli/ember-cli](https://github.com/ember-cli/ember-cli) 

```javascript
async startHttpServer() {
  this.app = this.express();
  const compression = require('compression');
  this.app.use(
    compression({
      filter(req, res) {
        let type = res.getHeader('Content-Type');

        if (res.getHeader('x-no-compression')) {
          // don't compress responses with this response header
          return false;
        } else if (type && type.indexOf('text/event-stream') > -1) {
          // don't attempt to compress server sent events
          return false;
        } else {
          return compression.filter(req, res);
        }
      },
    })
  );

  this.setupHttpServer();

  let options = this.startOptions;
  options.httpServer = this.httpServer;
  let liveReloadServer;

  if (options.path) {
    liveReloadServer = {
      setupMiddleware() {},
    };
  } else {
    liveReloadServer = new LiveReloadServer({
      app: this.app,
      ui: options.ui,
      watcher: options.watcher,
      project: options.project,
      httpServer: options.httpServer,
    });
  }

  const config = this.project.config(options.environment);
  const middlewareOptions = Object.assign({}, options, {
    rootURL: config.rootURL,
  });

  await liveReloadServer.setupMiddleware(this.startOptions);
  await this.processAppMiddlewares(middlewareOptions);
  await this.processAddonMiddlewares(middlewareOptions);

  return this.listen(options.port, options.host).catch(() => {
    throw new SilentError(
      `Could not serve on http://${this.displayHost(options.host)}:${options.port}. ` +
        `It is either in use or you do not have permission.`
    );
  });
}

```

[lib/tasks/server/express-server.js](https://github.com/ember-cli/ember-cli/blob/8c05d41d9764a3e938a99cabff6cf56dbd30cc3c/lib/tasks/server/express-server.js#L208-L264) · [More projects using compression →](https://dashboard.exa.ai/playground/search?q=compression%20GitHub%20projects)

**Quickstart**

```javascript
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);

```

From [README.md](https://github.com/expressjs/compression/blob/master/README.md)

## FAQ

### What is JSZip?

[JSZip](#jszip) creates, reads, and edits ZIP files from JavaScript. Each file in the archive can set its own DEFLATE compression level.

### What is lz-string?

[lz-string](#lz-string) compresses JavaScript strings for browser storage and URLs. Use compressToUTF16 for UTF-16-safe stored strings.

### How do I gzip data in JavaScript?

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

### How do I create a tar archive in Node.js?

[tar](#tar) creates and extracts tar archives in Node.js with an API modeled on the Unix tar command.

### Why can an asynchronous call be slower for a small input?

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

### Can pako change compression settings midway through a stream?

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

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript compression libraries pako fflate lz-string brotli-wasm code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
