Skip to the tool
Binary Translator Free tools

Text to hex converter

Type or paste text and get each byte in hex. Choose spaces, one unbroken run, 0x prefixes or \x escapes.

Updated · Written and checked by Murugan Vellaichamy

Waiting for input
Text
Binary
Try:

Byte by byte

Every byte of your input, with the place values that add up to it. Hover a row to find that byte in the output.

CharacterBinaryPlace valuesDecimalHex

How text becomes hex

Each character has a number, and hex writes that number in base 16. “A” is 65, which is 4 × 16 + 1, so it is 41 in hex. “a” is 97, or 61 in hex. A space is 20 and the digit “7” is 37.

In UTF-8, characters outside basic English take several bytes: “é” is C3 A9 and “€” is E2 82 AC. In Windows-1252 the same two characters are single bytes, E9 and 80, so the encoding you pick changes the hex.

Pick the output style to suit where the hex is going: “0x prefix, commas” for arrays in C, Java or JavaScript, and “\x escapes” for string literals in C or Python.

Worked example: hex 41
DigitPlace valueDigit × place value
41664
111

64 + 1 = 65 = A

Text to hex in code

In Python, "Hi!".encode("utf-8").hex() gives "486921". Add " " as an argument, as in .hex(" "), to put a space between the bytes.

On our other sites

Sources and method

Hex can be pasted as spaced pairs, one unbroken run (split into pairs), 0x prefixes or \x escapes. Each pair is one byte, and the bytes are decoded with the same rules as the binary translator.

Encoding to UTF-16 writes each 16-bit code unit of the text in the chosen byte order (low byte first for LE, high byte first for BE). The Encoding Standard defines decoders for UTF-16 but not encoders, so this step is the site’s own code.

Questions

Is hex the same as ASCII?

No. ASCII decides which number each character gets; hex is one way of writing that number. “A” is ASCII code 65, which is 41 in hex and 01000001 in binary.

Why are some characters two or more bytes?

UTF-8 uses one byte for the 128 ASCII characters and two to four bytes for everything else, including accented letters, other scripts and emoji.

Upper or lower case hex?

Either is correct; 6C and 6c are the same byte. The converter writes upper case, and reads both.

More converters

Copied