Storage & Files

Compression Streams

Probing…

Compression Streams is a web platform capability in the Storage & Files category. Gzip/deflate compression and decompression as native streams. Supported in Chromium 80+, Firefox 113+, and Safari 16.4+.

Try it

Loading demo…

Code

async function gzip(text) {
  const stream = new Blob([text]).stream().pipeThrough(new CompressionStream('gzip'))
  return new Uint8Array(await new Response(stream).arrayBuffer())
}

const packed = await gzip('hello '.repeat(50))

const back = new Blob([packed]).stream().pipeThrough(new DecompressionStream('gzip'))
console.log(await new Response(back).text())

Browser support

Chromium
80
Firefox
113
Safari
16.4

Frequently asked questions

Which browsers support Compression Streams?

Supported in Chromium 80+, Firefox 113+, and Safari 16.4+.

Does Compression Streams require HTTPS?

No. Compression Streams works without a secure context, though serving your site over HTTPS is always recommended.

What is Compression Streams used for?

Gzip/deflate compression and decompression as native streams.

Can I try Compression Streams in my browser?

Yes. shwcs.net runs a live Compression Streams demo that probes your current browser and lets you try the API. Everything runs locally — nothing is sent anywhere.

MDN reference ↗ Specification ↗