Text to Hex Converter

charcodehex
H
72
48
i
105
69

Show the working for hex → text

This converter turns characters into two-digit UTF-8 or ASCII bytes. If you have ASCII decimal codes rather than characters, use Hex to ASCII; for a plain number, use Decimal to Hex.

Going the other way? Convert hex back to text →

How do you convert text to hex?

Text to hex conversion replaces every character with the hexadecimal form of its ASCII or UTF-8 code, so a two-letter word becomes two groups of hexadecimal digits.

In short

Text to hex writes each byte of the text as two hex digits: "Hi" is 48 69. Find each character's UTF-8 code (H is 72), convert it to base 16, and separate the bytes with spaces; é is C3 A9.

  1. Take the first character and look up its code. H is 72.
  2. Convert that code to hexadecimal by repeated division or from the table. 72 is 48.
  3. Pad the result on the left with zeros until it is 2 digits: 48.
  4. Repeat for every character and separate the codes with a single space: Hi = 48 69.

Text to hex writes each character code in base 16, a compact form of the bits a computer stores; binary code explains how a letter becomes those bits.

Text to Hexadecimal Conversion Table

Every letter, digit and the space, with its code in all four bases. Find the character in the first column and read across: the Dec column is the code the method uses, and the Hex column is what this converter writes — 2 digits per character, zero-padded on the left. That column uses the digit set 0–9, A–F (A=10 … F=15; case-insensitive) and nothing else, each place worth 16ⁿ, and a value marked with the 0x prefix means the same thing. 0b marks binary, 0o octal, 0x hexadecimal; a leading # marks a hex colour. Hexadecimal is not case-sensitive (FF = ff); iToolHub writes hex digits in uppercase. This page writes one two-digit uppercase hex byte per character, single space between bytes. This page shows the rows you need; ASCII code chart (decimal, hex, octal, binary) carries all 128.

Text to Hexadecimal Conversion Table
CharDecHexOctBin
A654110101000001
B664210201000010
C674310301000011
D684410401000100
E694510501000101
F704610601000110
G714710701000111
H724811001001000
I734911101001001
J744A11201001010
K754B11301001011
L764C11401001100
M774D11501001101
N784E11601001110
O794F11701001111
P805012001010000
Q815112101010001
R825212201010010
S835312301010011
T845412401010100
U855512501010101
V865612601010110
W875712701010111
X885813001011000
Y895913101011001
Z905A13201011010
a976114101100001
b986214201100010
c996314301100011
d1006414401100100
e1016514501100101
f1026614601100110
g1036714701100111
h1046815001101000
i1056915101101001
j1066A15201101010
k1076B15301101011
l1086C15401101100
m1096D15501101101
n1106E15601101110
o1116F15701101111
p1127016001110000
q1137116101110001
r1147216201110010
s1157316301110011
t1167416401110100
u1177516501110101
v1187616601110110
w1197716701110111
x1207817001111000
y1217917101111001
z1227A17201111010
0483006000110000
1493106100110001
2503206200110010
3513306300110011
4523406400110100
5533506500110101
6543606600110110
7553706700110111
8563807000111000
9573907100111001
(space)322004000100000

The base this page writes, defined by the digits it uses, how a value is marked, and what each position is worth.

Base reference
BaseRadixDigits PrefixPlace worthTypical range
Hexadecimal160–9, A–F (A=10 … F=15; case-insensitive) 0x16ⁿ2 digits cover a byte (00–FF); 6 digits = RGB colour; 8 digits = 32-bit word

Worked Example: "Hi" to Hexadecimal

One character at a time, with the working written out. This is the same grid the converter shows when you turn on "show steps".

charcodehex
H
72
48
i
105
69

Result: Hi = 48 69

Take the first character, H. Its code is 72. Written in hexadecimal that is 48, which is 2 digits only once a leading zero is added: 48. The place values across the top of the grid show why — 72, and every column with a 1 in it contributes its own weight.

Every remaining character repeats the same three moves: find the code, write it in hexadecimal, pad it to 2 digits. i is 105, so 69. The groups then join in the order the characters were typed, separated by a single space.

To check a result, count the groups: an ASCII message has exactly one per character, spaces included. Then find any one group's row in the table above; its Dec column must match the code in the grid. A group one digit short means a leading zero was dropped, and one group too few means a space was trimmed from the input. An accented letter or an emoji is the one honest exception to the count: it takes two to four groups, and the converter's working shows them on one row under the character's code point.

Check it in reverse

The value goes back the way it came: 48 is code 72, which is H; 69 is code 105, which is i. Nothing is lost on the return trip, because every character keeps its own group and the groups keep their order. A decoder needs no extra information from the encoder — the fixed width tells it where each group ends, and the table tells it what each code means. To verify the result by hand, read the same hex bytes back as text and compare it with what you started from.

Worked examples: text to hex

Each example gives the value first, then the working. Click a value to load it in the converter.

How do you write "I love you" in hex?

"I love you" in text is 49 20 6C 6F 76 65 20 79 6F 75 in hex.

Method: one two-digit group per character, spaces included (20).

Load this value in the converter

How do you write "How are you" in hex?

"How are you" in text is 48 6F 77 20 61 72 65 20 79 6F 75 in hex.

Method: one two-digit group per character, spaces included (20).

Load this value in the converter

What is "Hi" in hex?

"Hi" in text is 48 69 in hex.

Method: H is code 72 = 48; i is code 105 = 69.

Load this value in the converter

What is "hello" in hex?

"hello" in text is 68 65 6C 6C 6F in hex.

Method: one two-digit group per character, spaces included (20).

Load this value in the converter

What is "Ana" in hex?

"Ana" in text is 41 6E 61 in hex.

Method: A is code 65 = 41; n is code 110 = 6E; a is code 97 = 61.

Load this value in the converter

What is the letter a in hex?

a in text is 61 in hex.

Method: a is code 97.

Load this value in the converter

What is the letter A in hex?

A in text is 41 in hex.

Method: A is code 65.

Load this value in the converter

What is the letter e in hex?

e in text is 65 in hex.

Method: e is code 101.

Load this value in the converter

What is the letter b in hex?

b in text is 62 in hex.

Method: b is code 98.

Load this value in the converter

What is the letter d in hex?

d in text is 64 in hex.

Method: d is code 100.

Load this value in the converter

What is the letter f in hex?

f in text is 66 in hex.

Method: f is code 102.

Load this value in the converter

What is the letter t in hex?

t in text is 74 in hex.

Method: t is code 116.

Load this value in the converter

Common phrases people convert: load one of these into the decoder

Every example above reverses exactly — turn those hex bytes back into a string.

What Changes the Hex Output?

Spaces and line breaks

A space is a character like any other: code 32, or 20. A trailing space converts too, which is the usual reason an output runs one group longer than expected.

Characters outside ASCII

UTF-8 encodes each character in 1 to 4 bytes. Characters 0–127 use one byte identical to ASCII, so ASCII text is valid UTF-8. é is U+00E9 and encodes as C3 A9 (2 bytes); € is U+20AC and encodes as E2 82 AC (3 bytes); 😀 is U+1F600 and encodes as F0 9F 98 80 (4 bytes). Written the way this page writes them, those are é = C3 A9, € = E2 82 AC and 😀 = F0 9F 98 80. The reason is set out in how ASCII, Unicode and UTF-8 differ.

Width and padding

ASCII defines 128 characters, codes 0–127, using 7 bits; in practice each code is stored in one 8-bit byte with a leading 0. That is why A is 41 here, not 41. Uppercase and lowercase differ by 32, which is bit 5, so a is 61.

Separator choice

The space between groups is a display choice; the bytes do not change. iToolHub's text-to-binary and text-to-hex converters write one 8-bit byte per character, separated by spaces. Pick no separator when the output feeds another program, a comma for a spreadsheet, or one group per line for a list.

Text to Hex in Code

The same rule in one line. Both take a string and return the hexadecimal codes, space-separated.

Python: ' '.join(format(b, '02X') for b in s.encode('utf-8'))
JavaScript: [...new TextEncoder().encode(s)].map(b => b.toString(16).toUpperCase().padStart(2, '0')).join(' ')

Common Mistakes

  • Dropping the leading zero, so A reads 41 instead of 41. The output then splits into the wrong groups.
  • Mixing widths inside one string. One short group shifts every character after it; pasted here, the converter names the group that is out of step.
  • Pasting codes instead of characters — that is a different conversion, and it lives on hex byte to ASCII code lookup.
  • Forgetting that the space between words is its own group, 20. The counts then disagree.

Frequently Asked Questions

Why does é become two hex bytes (C3 A9)?

Because é is outside ASCII and UTF-8 gives it more than one byte. UTF-8 encodes each character in 1 to 4 bytes. Characters 0–127 use one byte identical to ASCII, so ASCII text is valid UTF-8. Each byte is eight bits underneath — see binary code explained from the alphabet up.

Should hex be written in uppercase or lowercase?

Uppercase, on this site. Hex uses the digit set 0–9, A–F, each place worth 16ⁿ. 0b marks binary, 0o octal, 0x hexadecimal; a leading # marks a hex colour. Hexadecimal is not case-sensitive (FF = ff); iToolHub writes hex digits in uppercase.

How do you convert text to hex in Python?

Encode the string to bytes, then format each byte as two uppercase hex digits. The one-liner under Text to Hex in Code does that, and iToolHub's text-to-binary and text-to-hex converters write one 8-bit byte per character, separated by spaces.

Every value here reverses: the same bytes convert straight back in the hex byte to text direction.

The rest of the family sits on the full converter grid.