| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/docs/Web/API/Compression_Streams_API | [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 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.
The Fetch API's Response can be used to convert streams to:
ArrayBufferBlobUint8ArrayStringCompressionStreamCompresses a stream of data.
DecompressionStreamDecompresses 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 = blob.stream().pipeThrough(ds);
return await new Response(decompressedStream).blob();
}
| Specification |
|---|
| Compression # compression-stream |
This page was last modified on Sep 6, 2025 by MDN contributors.
Your 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 |