Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
80
80
113
16.4
80
16.4

The CompressionStream() constructor creates a new CompressionStream object which compresses a stream of data.

80
80
113
16.4
80
16.4
CompressionStream (brotli)
Non-standard

"brotli" compression

147
18.4
18.4
CompressionStream (deflate)

"deflate" compression

80
80
113
16.4
80
16.4
CompressionStream (deflate-raw)

"deflate-raw" compression

103
103
113
16.4
103
16.4
CompressionStream (gzip)

"gzip" compression

80
80
113
16.4
80
16.4

The readable read-only property of the CompressionStream interface returns a ReadableStream that emits compressed data as Uint8Array chunks.

80
80
113
16.4
80
16.4

The writable read-only property of the CompressionStream interface returns a WritableStream that accepts uncompressed data to be compressed, in the form of ArrayBuffer, TypedArray, or DataView chunks.

80
80
113
16.4
80
16.4

The DecompressionStream interface of the Compression Streams API decompresses a stream of data. It implements the same shape as a TransformStream, allowing it to be used in ReadableStream.pipeThrough() and similar methods.

80
80
113
16.4
80
16.4

The DecompressionStream() constructor creates a new DecompressionStream object which decompresses a stream of data.

80
80
113
16.4
80
16.4
DecompressionStream (brotli)
Non-standard

"brotli" compression

147
18.4
18.4
DecompressionStream (deflate)

"deflate" compression

80
80
113
16.4
80
16.4
DecompressionStream (deflate-raw)

"deflate-raw" compression

103
103
113
16.4
103
16.4
DecompressionStream (gzip)

"gzip" compression

80
80
113
16.4
80
16.4

The readable read-only property of the DecompressionStream interface returns a ReadableStream that emits decompressed data as Uint8Array chunks.

80
80
113
16.4
80
16.4

The writable read-only property of the DecompressionStream interface returns a WritableStream that accepts compressed data to be decompressed, in the form of ArrayBuffer, TypedArray, or DataView chunks.

80
80
113
16.4
80
16.4
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
const compressedReadableStream = inputReadableStream.pipeThrough(
  new CompressionStream("gzip"),
);

Use cases

  • Using Compression streams

    The CompressionStream interface of the Compression Streams API compresses a stream of data.

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.