SQLite 3 reference · String Functions

SQLite HEX() Function

Return the hexadecimal form of a value's bytes (its UTF-8 text for strings). Often used to display BLOBs.

SQLite 3

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

hex(X)

Parameters

ParameterDescription
X A BLOB or a value treated as text.

Return value

Uppercase hex text.

Examples

Text and BLOBsTry it yourself
SELECT hex('abc') AS text_hex, hex(x'00FF') AS blob_hex;

Output

text_hex | blob_hex
616263 | 00FF
Random IDsTry it yourself
SELECT hex(randomblob(4)) IS NOT NULL AS ok, length(hex(randomblob(16))) AS chars;

Output

ok | chars
1 | 32

Was this page helpful?