StringMash.com

Text to hex

Two digits a byte, which is the shortest way to write a byte exactly.

Conversion
7 characters
Updates as you type
Two digits a byte

Using the converter

Type on the left and two hex digits appear for each byte. Separator puts a space between bytes, a comma, or nothing at all, which is the form you want when pasting into code.

Swap the boxes to go the other way. The hex to text page starts in the decode direction if that's the job you arrived with.

Why two digits, always

A byte holds a number from 0 to 255. In hex that's 00 to FF, and it's never more or fewer than two digits. Four binary digits map onto exactly one hex digit, so eight map onto exactly two, with nothing left over.

Decimal has no such luck. A byte is one, two or three decimal digits depending on its value, so a run of decimal numbers needs separators to stay readable. Hex doesn't. 48692063616665 can be split into pairs by anyone, and that's why every hex dump, colour code and MAC address is written this way.

Accents and emoji cost more than one byte here too, on the same UTF-8 rules as binary. The é in the sample is c3 a9.

A-Z AND 0-9

Every character in two digits

A41
B42
C43
D44
E45
F46
G47
H48
I49
J4a
K4b
L4c
M4d
N4e
O4f
P50
Q51
R52
S53
T54
U55
V56
W57
X58
Y59
Z5a
030
131
232
333
434
535
636
737
838
939

IBM had to name it, and avoided the obvious word

Base 16 needed a name in the early 1960s and the obvious one was already in use. Writers had called it sexadecimal, built the ordinary way from the Latin for six and ten, and Bendix used that word in manuals into the 1960s.

IBM went with hexadecimal instead, mixing the Greek hexa with the Latin decim. It's a hybrid that classicists object to on principle, and the reason for it is generally understood to have been the first syllable of the alternative. The word arrived with the System/360 documentation and never budged.

The letters had competition too. Early machines used u through z, or k through p, for the digits past 9. A B C D E F won because it needed no new characters on a keypunch, and because sorting stayed sensible.

Related conversions

Text to binary shows the same bytes as bits, four times longer and easier to read one flag out of. Base64 packs three bytes into four characters, so it's denser than hex and unreadable by eye.

For the number behind a character rather than the bytes it's stored as, use the Unicode converter.

Questions

How do I convert text to hex?

Type it above. Each byte becomes two hexadecimal digits, and the separator control decides what goes between them.

Why is hex used instead of decimal for bytes?

One hex digit is exactly four bits, so a byte is always exactly two digits. Decimal needs one, two or three digits depending on the value, which makes a run of bytes ambiguous without separators.

What is 48 65 6c 6c 6f?

It's "Hello". 48 is H, 65 is e, and 6c appears twice for the two Ls.

Does hex handle emoji?

Yes. An emoji is encoded as its UTF-8 bytes, usually four of them, so it comes out as eight hex digits.