---
schema_version: "1"
id: f145f63a5adcea9637e075eea24c339d623a3d32b2296b395bc2286bcbb20450
title: toHex
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.12/dw-binaries-functions-tohex.md
canonical_url: https://docs.mulesoft.com/dataweave/2.12/dw-binaries-functions-tohex
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 07c4392c658ecdf393194723a68f50e63455f44f60f8390f116add9928171fac
description: MuleSoft Documentation Site
release: "2.12"
latest: false
---
---
product: DataWeave
version: 2.12
---

# toHex

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

## toHex(content: Binary): String

Transforms a binary value into a hexadecimal 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 <code>Binary</code> value to transform.</p></td></tr></tbody></table>

### Example

This example transforms a binary version of "Mule" (defined in the variable, `myBinary`) to
hexadecimal.

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Binaries
output application/json
var myBinary = "Mule" as Binary
var testType = typeOf(myBinary)
---
{
   "binaryToHex" : toHex(myBinary)
}
```

#### Output

```JSON
{ "binaryToHex": "4D756C65" }
```
