# Handlebars Helper Function: base64Encode

Converts plain text to Base64-encoded binary data.

## Availability

This helper is available in the Winter ’27 release of Marketing Cloud Next.

## Syntax

```handlebars
{{base64Encode stringToEncode characterEncoding="CHARSET"}}
```

## Parameters

| Parameter           | Type   | Description                                                                                                                             |
| ------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------- |
| `stringToEncode`    | String | Required. The string to encode.                                                                                                         |
| `characterEncoding` | String | The character encoding to use. Specify as a named parameter with one of these values: `ASCII`, `UTF-7`, `UTF-8`, `UTF-16`, or `UTF-32`. |

## Return Value

The function returns the Base64-encoded value of `stringToEncode`.

## Usage Example

This example encodes a coupon code before storing it in a marketing object, so the plain-text value isn't stored directly.

```handlebars
{{base64Encode "6dn28uqxocqu"}}
```

The function returns this Base64-encoded string:

```text
NmRuMjh1cXhvY3F1
```

### Encoding with UTF-16

This example encodes the same string, but specifies UTF-16 character encoding. Because UTF-16 uses more bytes per character, the encoded output is longer.

```handlebars
{{base64Encode "6dn28uqxocqu" characterEncoding="UTF-16"}}
```

The function returns:

```text
NgBkAG4AMgA4AHUAcQB4AG8AYwBxAHUA
```
