---
title: DecompressionStream
summary: An API for decompressing a stream of data.
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/class.DecompressionStream/
---

**Kind:** Class  
**Module:** [globals](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/)  
**Package:** @fastly/js-compute 4.0.1  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1176

An API for decompressing a stream of data.

**See also**

- [DecompressionStream on MDN](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream)

````javascript
In this example a request is made to httpbin.org/gzip and the response body is decompressed using gzip decompression.

View this example on [Fiddle](https://fiddle.fastly.dev/fiddle/637add51).

```js
async function app(event) {
 const backendResponse = await fetch("https://httpbin.org/gzip", { backend: "origin_0" });
 let resp = new Response(backendResponse.body.pipeThrough(new DecompressionStream("gzip")), backendResponse);
 resp.headers.delete('content-encoding');
 return resp;
}
addEventListener("fetch", event => event.respondWith(app(event)));
```
````

## Constructor

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1189

```javascript
new DecompressionStream(format: 'deflate' | 'deflate-raw' | 'gzip')
```

Creates a new `DecompressionStream` object which decompresses a stream of
data.

**Parameters**

- `format`: `'deflate' | 'deflate-raw' | 'gzip'` — The compression format to use.

**Throws**

- Throws a `TypeError` if the format passed to the constructor is not supported.

```js
const gzip = new DecompressionStream("gzip");
```

## Properties

### readable

**Type:** `ReadableStream<Uint8Array<ArrayBuffer>>`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1198

```js
let stream = new DecompressionStream("gzip");
console.log(stream.readable instanceof ReadableStream); // true
```

### writable

**Type:** `WritableStream<Uint8Array<ArrayBuffer>>`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1206

```js
let stream = new DecompressionStream("gzip");
console.log(stream.writable instanceof WritableStream); // true
```
