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

Transforms a decimal number into a hexadecimal number.

_Introduced in DataWeave version 2.2.0._

### 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(number: Null): Null

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

_Introduced in DataWeave version 2.2.0._
