---
title: TextDecoder
summary: TextDecoder takes a stream UTF-8 bytes as input and emits a stream of code points
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/class.TextDecoder/
---

**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#L963

TextDecoder takes a stream UTF-8 bytes as input and emits a stream of code points

**See also**

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

**Note**: On Fastly Compute, TextDecoder only supports UTF-8 bytes as input, and always operates
in non-fatal mode.

## Constructor

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

```javascript
new TextDecoder(label?: 'unicode-1-1-utf-8' | 'utf-8' | 'utf8')
```

**Parameters**

- `label`: `'unicode-1-1-utf-8' | 'utf-8' | 'utf8'` (optional)

## Properties

### encoding

**Type:** `'utf-8'`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L967

## Methods

### decode

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

```javascript
decode(input?: ArrayBuffer | ArrayBufferView): string
```

**Parameters**

- `input`: `ArrayBuffer | ArrayBufferView` (optional)

**Returns**

`string`
