---
schema_version: "1"
id: 0d853b9d1a301c1570897c9f489ed8988e2c8a5cead500428f7a33b981c0603a
title: toBase64
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.11/dw-binaries-functions-tobase64.md
canonical_url: https://docs.mulesoft.com/dataweave/2.11/dw-binaries-functions-tobase64
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 8fae57502f93ee7988cdc1d5fd45c9b62f307988ea0758bc0f9f2e7ca94d9790
description: MuleSoft Documentation Site
release: "2.11"
latest: false
---
---
product: DataWeave
version: 2.11
---

# toBase64

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## toBase64(content: Binary): String

Transforms a binary value into a Base64 string.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>content</code></p></td><td><p>The binary value to transform.</p></td></tr></tbody></table>

### Example

This example transforms a binary value into a Base64 encoded string. In this case, the binary value
represents an image.

#### Source

```DataWeave
%dw 2.0

import dw::Crypto
import toBase64 from dw::core::Binaries

var emailChecksum = Crypto::MD5("achaval@gmail.com" as Binary)
var image = readUrl(log("https://www.gravatar.com/avatar/$(emailChecksum)"), "application/octet-stream")

output application/json
---
toBase64(image)
```

#### Output

This example outputs a Base64 encoded string. The resulting string was shortened for readability
purposes:

```JSON
"/9j/4AAQSkZJRgABAQEAYABgAAD//..."
```
