---
schema_version: "1"
id: 0888a88c97596e93ab0f5c1cc2b3c85a11ba91e8c93ea8396111a8df5ec21abf
title: "Handlebars Helper Function: base64Encode"
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/handlebars/reference/utility/mcn-handlebars-reference-utility-base64encode.md
canonical_url: https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/references/mcn-handlebars-utility-references/mcn-handlebars-reference-utility-base64encode.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: cd20476dda4cf7b0a3d02d82b4cdf4c8e4072136d26783f54016e1e37d7f0a12
products:
  - Handlebars for Marketing Cloud Next
  - Marketing Cloud
---
# 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
```
