Advertisement

Text to hexadecimal converter

Hexadecimal writes each byte as two digits, which makes it a compact way to inspect text, compare encodings or build a byte sequence for a program. This page converts your text to hex in five encodings and lets you choose the case and separator, so the output matches the format the receiving tool expects.

Calculator

Hexadecimal result
48 69
Bytes
2
Characters in the text
2

Advertisement

How this calculator works

A byte holds a value from 0 to 255, which is exactly two hexadecimal digits from 00 to FF. This page encodes the text first, then writes each byte as a two-digit hex pair. The encoding matters: in UTF-8 a plain English letter is one byte, an accented letter may be two and an emoji may be four, while Windows-1252 is one byte per character and cannot encode anything outside its table. The case and prefix options change only how the numbers are written, not the bytes themselves.

Formula

hex = each byte of the encoded text, written as two hexadecimal digits and joined by the chosen separator. A byte is 0 to 255, so two hex digits always suffice. UTF-8 uses one to four bytes per character, UTF-16 uses two bytes per 16-bit code unit, and Windows-1252 uses one byte per character inside its table.

Worked example

Hi in UTF-8 is 48 69, because H is 0x48 and i is 0x69. The euro sign is 0x20AC: UTF-8 needs three bytes, E2 82 AC, while Windows-1252 writes it as the single byte 80. With the 0x prefix and no separator, the UTF-8 euro sign becomes 0xE20x820xAC, which is why a separator is usually easier to read.

Advertisement

Frequently asked questions

Is the hex output the same as a hex colour code?

No. A colour code such as #FF8800 is a fixed six-digit number describing red, green and blue. This page produces a variable-length sequence of bytes, and its length depends on the text and the encoding. The two only look similar.

Why are there two digits per byte?

Hexadecimal is base 16, and one hex digit carries four bits. Two digits carry eight bits, exactly one byte. A byte value of 10 is 0A, not A, so the leading zero is kept to make every byte two digits wide.

Which encoding should I choose?

Use UTF-8 for the web and for most modern systems. Choose UTF-16 when a file format or a Windows API asks for it, and Windows-1252 only for old Western European data. The same letters produce different hex in each, so the reader must know which one was used.

Why does Windows-1252 fail on some text?

Windows-1252 has only 256 byte values and covers Western European scripts. Characters such as Chinese, Arabic or many emoji have no byte in that table. The page reports the first character it could not encode; switch to UTF-8 if the receiving system accepts it.

How do I turn the hex back into text?

Remove the separators and the 0x prefixes, then decode pairs of digits as bytes using the same character encoding. A single wrong pair changes one character or breaks the sequence, so keep encoding information with the hex rather than assuming it.

Sources

Advertisement