Web Dev Tools

Compression & Archives

gzip, brotli, zstd, zip, tar — in Node, the browser, and at the edge.

Compression algorithms

  • zstd — fastest modern algorithm; 2–5× faster than gzip at similar ratios. Use @hpcc-js/wasm-zstd in browsers, node:zlib createZstdCompress in Node 22+.
  • brotli — best compression for HTTP text; built into all browsers. Use brotli-wasm in browsers, node:zlib brotli APIs in Node.
  • gzip — universal; built into Node and every browser; fine for most things.
  • deflate / raw deflate — used inside zip and gzip.

Pure-JS / browser libs

  • fflate — fastest pure-JS compression in 2026; sync + async APIs; tiny bundle. Default for browser compression.
  • pako — long-running pure-JS zlib port; bigger than fflate.
  • brotli-wasm — Brotli in the browser.
  • lz-string — specialized for compressing UTF-16 strings into URL-safe forms; great for compressing localStorage data.

Zip / archives

  • @zip.js/zip.js — modern, streaming, browser + Node; the default for ZIP in 2026.
  • fflate's zip APIs — also good, smaller bundle.
  • JSZip — older, larger; still widely used.
  • archiver — Node-only, multi-format (zip, tar); when you need a Buffer-out workhorse.
  • tar-stream / tar-fs — streaming tar.
  • node-7z — wraps the 7z CLI for .7z and other formats.

Streaming / large-file friendly

  • Node node:zlib — built-in streaming gzip / deflate / brotli / zstd.
  • @zip.js/zip.js streams — handle multi-GB ZIPs without loading into memory.
  • tar-fs — stream a tarball straight to/from filesystem.

At the edge / HTTP

  • Cloudflare auto-brotlies / gzips responses. Don't compress at origin if your CDN does it.
  • Vercel / Netlify same.
  • Set Content-Encoding correctly when you do compress at origin.

Use cases

  • Compress CSV before upload: fflate gzip + the user's bandwidth wins.
  • Single-file ZIP download from browser: @zip.js/zip.js.
  • Tar a folder for backup: tar-fs.
  • Compress localStorage: lz-string.
  • Ship pre-compressed static assets: Vite's vite-plugin-compression, Webpack's CompressionPlugin.

Decompression for incoming data

  • DecompressionStream API — built into modern browsers; supports gzip / deflate / brotli / zstd.
  • Always validate decompressed size — "zip bombs" and decompression-size DoS are real.

Pick this if…

  • Default browser compression: fflate.
  • ZIPs in the browser: @zip.js/zip.js.
  • Big tarballs in Node: tar-fs + node:zlib.
  • Compress text for localStorage: lz-string.
  • HTTP responses: let your CDN do it; don't double-compress.

On this page