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

# hex_decode_binary

> Decodes a hex encoded string to a binary.

Decodes a hex encoded string to a binary.

This function is supported from v3.0.

## Syntax

```Haskell theme={null}
hex_decode_binary(str);
```

## Parameters

`str`: the string to convert. The supported data type is VARCHAR.

An empty binary is returned if any of the following situations occur:

* The length of the string is 0 or the number of characters in the string is an odd number.
* The string contains characters other than `[0-9]`, `[a-z]`, and `[A-Z]`.

## Return value

Returns a value of the VARBINARY type.

## Examples

```Plain Text theme={null}
mysql> select hex(hex_decode_binary(hex("Hello StarRocks")));
+------------------------------------------------+
| hex(hex_decode_binary(hex('Hello StarRocks'))) |
+------------------------------------------------+
| 48656C6C6F2053746172526F636B73                 |
+------------------------------------------------+

mysql> select hex_decode_binary(NULL);
+--------------------------------------------------+
| hex_decode_binary(NULL)                          |
+--------------------------------------------------+
| NULL                                             |
+--------------------------------------------------+
```

## Keywords

HEX\_DECODE\_BINARY


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