Text to hex

Convert text to hex bytes in UTF-8, UTF-16 or ISO 8859-1, in six output formats, with a worked example.

loading Text to hex
About this tool

Text to hex: what the bytes are

Text is stored as bytes, and a byte (8 bits) is written with two hexadecimal digits from 00 to FF. Converting text to hex means encoding the string into bytes first and then writing each byte in base 16. The result depends on the encoding: "A" is 41 in every common one, but an accented letter is one, two or more bytes depending on the encoding you pick. This page opens the converter in the text to hex direction, with a sample loaded.

Worked example: Hello

The same five bytes in the six output formats of the tool:

FormatResult
Spaced48 65 6c 6c 6f
Compact48656c6c6f
0x prefix0x48 0x65 0x6c 0x6c 0x6f
Escaped (\x)\x48\x65\x6c\x6c\x6f
C array0x48, 0x65, 0x6c, 0x6c, 0x6f
Colons48:65:6c:6c:6f

The encoding changes the bytes

"Olá" in four encodings. Only the accented letter changes; note the byte counts:

EncodingBytes in hexCount
UTF-84f 6c c3 a14
UTF-16LE4f 00 6c 00 e1 006
UTF-16BE00 4f 00 6c 00 e16
ISO-8859-14f 6c e13

ISO 8859-1 and ASCII refuse what they cannot hold instead of writing a "?": a euro sign or an emoji gives an error that names the character and its code point.

Quick reference: letters and digits

CharacterHex
A41
B42
C43
a61
b62
c63
030
939
(space)20

Digits start at 30, upper-case letters at 41 and lower-case at 61, so adding 20 to the hex of a capital gives the lower-case letter.

Where each format is used

  • 0x48, 0x65 and the C array: source code in C, C++, Arduino and many other languages.
  • \x48\x65: string escapes in Python, Bash, JavaScript and C.
  • 48:65: the notation of MAC addresses and certificate fingerprints.
  • Compact 48656c6c6f: hashes, tokens and databases that store binary as hex.

How to use the converter

  1. Type or paste the text; the direction is already text to hex.
  2. Pick the encoding (UTF-8 by default) and the output format, upper or lower case, and how many bytes per line.
  3. Copy the result; the byte count is shown next to it.

Frequently asked questions

What is "Hello" in hex?

48 65 6c 6c 6f in UTF-8, ASCII and ISO 8859-1: one byte per letter. With 0x prefixes it is 0x48 0x65 0x6c 0x6c 0x6f.

Why does the same text give different hex in UTF-8 and UTF-16?

UTF-8 uses one byte for ASCII and more for the rest; UTF-16 uses two bytes per character (and four for emoji), in little or big endian order. The bytes differ, the characters are the same.

Is hex the same as Base16?

Yes: hexadecimal text of bytes is Base16 as defined in RFC 4648, usually in upper case there and in lower case in most tools.

Report a problem