Upload a file
  1. base64hub
  2. Other bases
  3. Text to hex

Text to Hex: String and ASCII to Hexadecimal

Type or paste text to see its bytes in hex: Hello is 48656c6c6f. Choose the charset, the letter case and a separator such as a space, :, 0x or \x.

Free no sign-up, no limits Local nothing uploaded \x escapes ready for C and Python strings Updated Oct 27, 2026
Input 0Bytes 0 BOutput 0

Processed in your browser. This page cannot send your data anywhere – how we know

How to convert text to hex

  1. Type or paste the text into Input · Text. The hex appears in Output · Hex as you type.
  2. Under the input, Charset decides how characters become bytes. Leave it on UTF-8 unless the receiving system expects something else.
  3. Under the output, pick Case (lowercase or UPPERCASE), Separator (none, space, :, 0x or \x) and Bytes per line (none, 16 or 32).
  4. Copy output or Download the result. The Hex → Text toggle turns it back into text, as does Hex to Text.

Output styles

The separator and case options cover the usual places hex gets pasted into. For the text Hi!:

SettingsOutputWhere it fits
none, lowercase486921hashes, URLs, JSON
space, UPPERCASE48 69 21hex editors, protocol docs
:48:69:21fingerprints, MAC-style lists
0x0x48 0x69 0x21C and assembler sources
\x\x48\x69\x21string escapes in C, Python, Bash printf

The \x form drops straight into a string literal: printf '\x48\x69\x21' in Bash prints Hi!. Bytes per line breaks long output into rows of 16 or 32 bytes so you can count offsets by eye.

One character, one or more bytes

ASCII characters are one byte each, and UTF-8 keeps them identical, so for English text both charsets give the same hex. Everything else depends on the charset:

TextUTF-8ISO-8859-1UTF-16LE
A414141 00
éc3 a9e9e9 00
€e2 82 acnot availableac 20
👋f0 9f 91 8bnot available3d d8 4b dc

Characters that a charset cannot represent are replaced with ?, and the status line says how many were replaced. If hex from another system does not match yours, check the charset on both sides first.

Finding invisible characters

Converting to hex is the quickest way to see characters that look like nothing on screen. Two strings that print identically can differ in their bytes:

Hex in UTF-8Character
20normal space
c2 a0no-break space, common in text copied from web pages and Word
e2 80 8bzero-width space
ef bb bfbyte order mark at the start of a file
0d 0aWindows line break (0a alone on Linux and macOS)

If a password, API key or config value is “correct but rejected”, paste it here with Separator set to space and look for any of these. The same check helps before encoding text as Base64 with Text to Base64: Base64 keeps every invisible byte, so they survive into the encoded value.

Text to hex in code

"Hi!".encode("utf-8").hex()       # '486921'
"Hi!".encode("utf-8").hex(" ")    # '48 69 21'  (separator argument, Python 3.8+)
"é".encode("latin-1").hex()       # 'e9'
const hex = Array.from(new TextEncoder().encode("café"),
  b => b.toString(16).padStart(2, "0")).join(" ");
// '63 61 66 c3 a9'

TextEncoder always produces UTF-8. The JavaScript and Python pages show the matching Base64 calls.

FAQ

How do I convert a string to hex?

Paste the string into the input. Each character becomes its byte values in the chosen charset, two hex digits per byte. In Python the same is "Hello".encode("utf-8").hex().

What is "Hello" in hex?

48 65 6c 6c 6f in ASCII and UTF-8, which agree for plain English letters. In UTF-16LE it is 48 00 65 00 6c 00 6c 00 6f 00.

Why does é become two bytes, c3 a9?

UTF-8 encodes every character above U+007F with two to four bytes. Set Charset to ISO-8859-1 (Latin-1) or Windows-1252 if you need the single byte e9.

How do I get hex with 0x in front of every byte?

Set Separator to 0x. The output then reads 0x48 0x65 0x6c 0x6c 0x6f. For a full C or Rust array literal, Base64 to Byte Array writes the declaration as well.