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

# 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._
