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

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