---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# TextEncoder.encode()

The **`TextEncoder.encode()`** method takes a string as input, and returns a `Uint8Array` containing the text given in parameters encoded with the specific method for that `TextEncoder` object.

## Syntax

```js
encode(string)
```

### Parameters

- `string`
  - : A string containing the text to encode.

### Return value

A `Uint8Array` object.
