# BASE64\_ENCODE

**The function BASE64\_ENCODE accepts a** [**String**](../../variable-data-types/the-text-variable-data-type) **and** [**base64**](https://en.wikipedia.org/wiki/Base64) **encodes that string.**

While any arbitrary data may be encoded using base64, the BASE64\_ENCODE function only encodes Strings. See [Encoding in Airscript (URLs & Base64)](../../working-with-data/airscript-quick-start/working-with-urls-and-base64) for more details.

### Limitations

The size limit of the string parameter to be encoded is 1MB.

#### Declaration

```javascript
BASE64_ENCODE(string) -> encoded_string
```

#### Parameters

**string** (type: _string_) The string to be encoded as base64.

#### Return Values

**encoded\_string** (type: _string_) The base64 encoded string.

#### Examples

The BASE64\_ENCODE function is needed when interacting with an external system that requires a base64 encoded string. For example, although [Data Operations](../../data-operations/data-operation-overview) take care of most of the hard work for you, certain authentication schemes require an access token to be base64 encoded. Assuming that the variable **access\_token** held the string \*\*"top secret!",\*\*we might set the Authorization header with this expression.

```javascript
"Bearer {{BASE64_ENCODE(access_token)}}" -> "Bearer dG9wIHNlY3JldCE="
```

#### Discussion

The function [BASE64\_DECODE](base64_decode) is the opposite operation to BASE64\_ENCODE. Rather than encoding a String, it will decode it. Encoding, and then decoding a String will produce the original String.

```javascript
BASE64_DECODE(BASE64_ENCODE("Hello, world")) -> "Hello, world"
```
