---
schema_version: "1"
id: 40178af9b5e55bb3faab3b7c236698c27c3929f50d571bae81244eae4c5e9fd3
title: Base64Encode()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/utilities/mc-ampscript-reference-utilities-base64-encode.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-utilities/mc-ampscript-reference-utilities-base64-encode.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: f7eb76961ae6e1bf69e9b7c784869d243a69e2ea4bf6cb5dc0df65c2324c0f1f
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# Base64Encode()

Converts plain text to Base64-encoded binary data.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>✅ Yes</td>
  </tr>
</table>

## Syntax

```
Base64Encode(stringToEncode, characterEncoding)
```

The `Base64Encode()` function has two parameters:

- `stringToEncode` (string): Required. The string to encode to Base64.
- `characterEncoding` (string): The character encoding type to use when encoding the string. Accepted values are `ASCII`, `UTF-7`, `UTF-8`, `UTF-16`, and `UTF-32`.

## Usage

To use the function, pass it the string that you want to encode. Optionally, specify the type of character encoding to use.

```
%%[
  Var @couponCode, @couponCodeB64
  Set @couponCode = "6dn28uqxocqu"
  Set @couponCodeB64 = Base64Encode(@couponCode)
]%%
<p>%%=v(@couponCodeB64)=%%</p>
```

The example code outputs a string encoded in Base64.

```
NmRuMjh1cXhvY3F1
```
