Compression Streams API

The Compression Streams API provides a JavaScript API for compressing and decompressing streams of data using the gzip or deflate formats.

Built in compression means that JavaScript applications will not need to include a compression library, which makes the download size of the application smaller.


Compresses a stream of data.
Decompresses a stream of data.


In this example a stream is compressed using gzip compression.

const compressedReadableStream = inputReadableStream.pipeThrough(new CompressionStream('gzip'));

In the following example a function decompresses a blob using gzip.

async function DecompressBlob(blob) {
  const ds = new DecompressionStream('gzip');
  const decompressedStream =;
  return await new Response(decompressedStream).blob();


Specification Status Comment
Compression Streams Draft Initial definition.

Browser compatibility

BCD tables only load in the browser