> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# HEX

> Returns the hexadecimal representation of a number, string or binary value.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns NULL when an argument is NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
hex(value)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s), STRING or BINARY | Yes | Numeric values are converted to BIGINT; string/binary bytes are encoded directly. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |

## Returns

* Type: STRING
* Possible values: Uppercase hexadecimal characters. Numeric zero returns 0; string/binary zero bytes retain two hex characters per byte.
* NULL behavior: Returns NULL when an argument is NULL.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* Negative integer values use their 64-bit two's-complement bit representation.
* Strings are encoded using UTF-8 bytes.
* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

## Examples

### Value and NULL input

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT hex(17) AS number, hex('ABC') AS text, hex(X'00FF') AS binary;
```

| number | text | binary |
| - | - | - |
| 11 | 414243 | 00FF |

### Empty text and binary data

In the result table, `''` denotes an empty string.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT hex('') AS empty_text, hex(X'00FF') AS binary_value;
```

| empty\_text | binary\_value |
| - | - |
| `''` | 00FF |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.