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

# toHex

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

## toHex(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" }
```
