| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/docs/Web/API/CompressionStream/CompressionStream | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since May 2023.
* Some parts of this feature may have varying levels of support.
Note: This feature is available in Web Workers.
The CompressionStream() constructor creates a new CompressionStream object which compresses a stream of data.
new CompressionStream(format)
formatOne of the following allowed compression formats:
"brotli"Compresses the stream using the Brotli algorithm.
"gzip"Compresses the stream using the GZIP format.
"deflate"Compresses the stream using the DEFLATE algorithm in ZLIB Compressed Data Format. The ZLIB format includes a header with information about the compression method and the uncompressed size of the data, and a trailing checksum for verifying the integrity of the data
"deflate-raw"Compresses the stream using the DEFLATE algorithm without a header and trailing checksum.
"zstd"Compresses the stream using the ZSTD algorithm.
TypeErrorThrown if the format passed to the constructor is not supported.
In this example a stream is compressed using gzip compression.
const compressedReadableStream = inputReadableStream.pipeThrough(
new CompressionStream("gzip"),
);
| Specification |
|---|
| Compression # dom-compressionstream-compressionstream |
This page was last modified on Jun 22, 2026 by MDN contributors.
CompressionStreamYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |