Text to hex converter

Turn text into hexadecimal bytes in the format your code expects: spaced pairs, a continuous string, 0x arrays, \x escapes or percent-encoding.

7 chars · 10 bytes

Why hex, not binary?

Every hex digit is exactly four bits, so a byte is always two hex digits. It's compact enough to read and still maps one-to-one onto the underlying bits, which is why hex editors, network captures, colour codes (#7F3FBF) and memory addresses all use it.

The example above shows the difference between ASCII and UTF-8: “Caf” and “5” are one byte each, “é” is two bytes (C3 A9) and “€” is three (E2 82 AC). To look up any single code point with its UTF-8 and UTF-16 forms, use the Unicode converter.

Text to hex chart (printable ASCII)

CharHexDec
space2032
!2133
"2234
#2335
$2436
%2537
&2638
'2739
(2840
)2941
*2A42
+2B43
,2C44
-2D45
.2E46
/2F47
03048
13149
23250
33351
43452
53553
63654
73755
83856
93957
:3A58
;3B59
<3C60
=3D61
>3E62
?3F63
CharHexDec
@4064
A4165
B4266
C4367
D4468
E4569
F4670
G4771
H4872
I4973
J4A74
K4B75
L4C76
M4D77
N4E78
O4F79
P5080
Q5181
R5282
S5383
T5484
U5585
V5686
W5787
X5888
Y5989
Z5A90
[5B91
\5C92
]5D93
^5E94
_5F95
CharHexDec
`6096
a6197
b6298
c6399
d64100
e65101
f66102
g67103
h68104
i69105
j6A106
k6B107
l6C108
m6D109
n6E110
o6F111
p70112
q71113
r72114
s73115
t74116
u75117
v76118
w77119
x78120
y79121
z7A122
{7B123
|7C124
}7D125
~7E126

Questions people ask

How do I convert text to hex?

Encode each character as UTF-8 bytes, then write each byte as two hexadecimal digits. “A” is byte 65, which is 41 in hex.

How do I convert ASCII to hex?

The same way: ASCII characters are single bytes, so each becomes exactly two hex digits. “Hi” = 48 69.

Which output style should I use?

Spaced pairs are easiest to read. Use 0x48, 0x65 for C/C++/JavaScript arrays, \x48 for string literals in C, Python and shell, and %48 for URLs.

Why are some characters more than two hex digits?

Characters outside ASCII take 2–4 UTF-8 bytes. “é” is C3 A9 and “€” is E2 82 AC.