---
schema_version: "1"
id: 02c4aeec574019da14a238cb90f3de513fd3cf06b0e4209503f7ce2ac441bd26
title: toHex
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dw-numbers-functions-tohex.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dw-numbers-functions-tohex
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 64d118442c51d8e41e9895d48e3beb4501de71abb275b82fab857d35b8d180cf
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(Number): String

Transforms a decimal number into a hexadecimal number.

_Introduced in DataWeave 2.2.0. Supported by Mule 4.2 and later._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>number</code></p></td><td><p>The input number.</p></td></tr></tbody></table>

### Example

This example shows how `toHex` behaves with different inputs.

#### Source

```DataWeave
%dw 2.0
import toHex from dw::core::Numbers
output application/json
---
{
    a: toHex(-1),
    b: toHex(100000000000000000000000000000000000000000000000000000000000000),
    c: toHex(0),
    d: toHex(null),
    e: toHex(15),
}
```

#### Output

```JSON
{
  "a": "-1",
  "b": "3e3aeb4ae1383562f4b82261d969f7ac94ca4000000000000000",
  "c": "0",
  "d": null,
  "e": "f"
}
```

## toHex(Null): Null

Helper function that enables `toHex` to work with null value.
