---
schema_version: "1"
id: 3a5c98dd9e3777136fc465284eb67c21bfd16a04fe9a686a036d23b27d4e288a
title: toBase64
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-binaries-functions-tobase64.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-binaries-functions-tobase64
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 7dc0cb48b85be11d7a76ab3ef5350a8bf8a8986f1076b6483f0b3f406c3afa40
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

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