HEX_DECODE()

All functions > STRING > HEX_DECODE()

Decodes a contiguous hexadecimal string back to plain text.

Signatures

Returns: Decoded string

HEX_DECODE(hex_digits: VARCHAR) → VARCHAR
sql
ParameterTypeRequiredDescription
hex_digitsVARCHARYesHex string (even length; mixed case allowed)

Notes

  • Requires an even number of hex digits; malformed input fails at run time
  • Interprets decoded bytes as text (invalid byte sequences fail at run time)
  • Returns NULL if the input is NULL (use NULL(VARCHAR); bare NULL fails inference)
  • Inverse of HEX_ENCODE for valid round-trip payloads

See also

Examples

FeatureQL
SELECT
    f1 := HEX_DECODE('68656c6c6f'), -- Lowercase hex digits
    f2 := HEX_DECODE(''), -- Empty hex decodes to empty string
    f3 := HEX_DECODE(NULL(VARCHAR)) -- NULL yields NULL
;
Result
f1 VARCHARf2 VARCHARf3 VARCHAR
hello(empty)NULL

Last update at: 2026/05/26 17:22:09