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

# 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//..."
```
