# HEX

> HEX function in StackQL: the upper-case hexadecimal rendering of the bytes of a value.

Source: https://stackql.io/language-spec/functions/string/hex

Returns the bytes of a value as an upper-case hexadecimal string.  A number is converted to its text form first, so `HEX(255)` encodes the characters `255`, not the integer.

See also:  
[[` SELECT `]](/language-spec/select) [[` PRINTF `]](/language-spec/functions/string/printf) [[ MD5 ]](/language-spec/functions/hash/md5)

* * * 

## Syntax

```sql
SELECT HEX(value) FROM <multipartIdentifier>;
```

## Arguments

__*value*__  
A string, number or BLOB.

## Return Value(s)
Returns a string.  `HEX(NULL)` returns an empty string.

* * *

## Examples

### Encode values as hexadecimal

The following query encodes a string and a number:

```sql
SELECT HEX('stackql') AS h, HEX(255) AS n;
```

```
|----------------|--------|
|       h        |   n    |
|----------------|--------|
| 737461636B716C | 323535 |
|----------------|--------|
```

For more information, see [https://www.sqlite.org/lang_corefunc.html#hex](https://www.sqlite.org/lang_corefunc.html#hex)
