Text to hex converter

Type or paste text and get its hex bytes as you type: Hello is 48 65 6C 6C 6F. Pick the encoding and output style, and open "Show each character" to see every letter as decimal, hex and binary.

Hex to text

Show each character
0 bytes
Checked byTomeshia Brock
Reviewed byKhushboo Gupta
Last updated · How we test

Runs in your browser. Nothing you type is uploaded.

How to use the converter

  1. Type or paste text in the left box. Each character turns into hex as you type.
  2. Leave Encoding on UTF-8 unless your data comes from an older system that uses Windows-1252, Latin-1 or another code page.
  3. Pick an output style: uppercase, lowercase, a 0x prefix for C arrays or a \x prefix for string escapes. The Separator menu under the box sets spaces, commas, new lines or nothing between bytes.
  4. Copy, download or share the result.

Open file loads a .txt file, and you can drop a file on the input box. To go back the other way, click the Hex to text tab above the tool; it carries your hex across.

How to convert text to hex

A computer stores each character as a number called its character code. For English letters, digits and punctuation that code comes from the ASCII table. Text to hex just writes each code in base 16, which always takes two digits per byte.

The word Hello converted to hex one letter at a time: H is 72 or 48, e is 101 or 65, l is 108 or 6C, and o is 111 or 6F, giving 48 65 6C 6C 6F.

H is code 72, which is 48 in hex. e is 101, or 65. l is 108, or 6C, and o is 111, or 6F. Put them in order and Hello becomes 48 65 6C 6C 6F.

Converting one character by hand

Converting the letter A to hex by hand: its ASCII code is 65, 65 divided by 16 is 4 remainder 1, so A is 41 in hex. The letter z is 122, which gives 7A.

Divide the character code by 16. The whole-number answer is the first hex digit and the remainder is the second, with 10 to 15 written as A to F. A space is code 32, and 32 ÷ 16 = 2 remainder 0, so a space is 20. An exclamation mark is 33, which gives 21.

ASCII to hex table

CharacterDecimalHexBinary
space322000100000
!332100100001
#352300100011
.462E00101110
0483000110000
9573900111001
@644001000000
A654101000001
Z905A01011010
a976101100001
z1227A01111010
new line100A00001010

Capital letters run from 41 to 5A and small letters from 61 to 7A, so the same letter in the two cases is always 20 apart in hex. All 128 codes are in the ASCII table.

Worked examples

TextHex
Hi48 69
OK!4F 4B 21
ABC41 42 43
12331 32 33
binary62 69 6E 61 72 79
Hello World48 65 6C 6C 6F 20 57 6F 72 6C 64

Notice that the text 123 becomes 31 32 33, one byte per digit. The number 123 is something else: it is 7B in hex, which is what the decimal to hex converter gives you.

Text to hex in UTF-8 and other encodings

For plain English, ASCII and UTF-8 produce exactly the same bytes. The difference shows up with accented letters, other alphabets and emoji. UTF-8 stores those in two to four bytes, following the rules in RFC 3629, the UTF-8 standard, while an older single-byte encoding such as Windows-1252 uses one byte but only covers a few hundred characters.

CharacterUTF-8UTF-16 (big endian)Windows-1252
éC3 A900 E9E9
ñC3 B100 F1F1
€E2 82 AC20 AC80
😀F0 9F 98 80D8 3D DE 00not available

If the hex you need has to match another program, use the same encoding that program used. To see the Unicode code point behind each character instead of its bytes, try the Unicode converter.

Output formats

  • Uppercase (48 65 6C) is the usual way hex is printed.
  • Lowercase (48 65 6c) matches what Python and most command-line tools print.
  • 0x prefix (0x48, 0x65) with the Comma separator pastes straight into a C, Java or JavaScript array.
  • \x prefix (\x48\x65) with no separator is an escaped string for Python, C or a shell.
  • No separator (48656C6C6F) is the compact form used in URLs, hashes and many APIs.

Text to hex in Python, JavaScript and the command line

Python: "Hello".encode("utf-8").hex() returns '48656c6c6f', and .hex(" ") adds spaces (Python 3.8 and later). Encoding the string to bytes is the step that decides which hex you get for non-ASCII text. JavaScript: [...new TextEncoder().encode("Hello")].map(b => b.toString(16).padStart(2, "0")).join(" ") returns "48 65 6c 6c 6f". TextEncoder on MDN confirms that it always encodes to UTF-8.

On Linux and macOS, echo -n Hello | xxd -p prints 48656c6c6f. The -n matters: without it, echo adds a new line and you get an extra 0a at the end.

Frequently asked questions

How do I convert text to hex?

Find each character's code, then write the code as two hex digits. Paste the text into the converter above and it does every character at once.

What is "Hello" in hex?

48 65 6C 6C 6F. Written without spaces it is 48656C6C6F.

What is a space in hex?

20, which is 32 in decimal. A new line is 0A and a tab is 09.

Is ASCII to hex the same as text to hex?

For English letters, digits and common symbols, yes. ASCII only covers 128 characters, so text with accents or emoji needs an encoding such as UTF-8, which this tool uses by default.

Why does é turn into two bytes?

UTF-8 stores every character above code 127 in more than one byte. é is C3 A9 in UTF-8. Pick Windows-1252 or ISO-8859-1 under Encoding if you need the single byte E9.

How do I convert hex back to text?

Use the hex to text converter, or click its tab above the tool to take your result with you.

Is my text sent anywhere?

No. The conversion runs in your browser and nothing you type is uploaded.

Scroll to Top