Hex Encoding Guide: See the Bytes, Not a Secret
When you need to know what a string actually contains, hex is the most direct view. It is a notation, not a protection.
When to flatten text into bytes
The same sentence renders differently on two systems, an API rejects a character, a config value has an invisible space at the end. In each case, what you see and what is stored are different things. Hex makes the gap obvious: a space is 20, a newline is 0a, a tab is 09.
It is also the practical way to check protocol documentation. Many fields are defined in bytes — a two-byte header, a one-byte flag — so converting a string and comparing it byte by byte beats squinting at the original text.
- Hunting invisible characters: space 20, newline 0a, tab 09
- Checking fixed-length headers and protocol fields
- Comparing two strings that look identical
- Confirming how many bytes a character really takes
Read the output with three rules in mind
First, the encoding is UTF-8, not UTF-16. A Latin letter is one byte, a common Chinese character is usually three, and most emoji take four. Seeing a Chinese character become e4 b8 ad is not a bug; it is the definition of UTF-8.
Second, every byte is exactly two digits, and the spaces are separators rather than data. Third, the 0x prefix is a writing convention: paste it or leave it out, but do not treat it as content. Lowercase and uppercase digits mean the same thing.
- One Chinese character: usually 3 bytes; emoji: usually 4
- Two lowercase digits per byte, space-separated
- CRLF adds 0d — normalise line endings before comparing
It is not encryption, and not a file format
Hex has no key. Anyone can reverse it in one step, so it cannot hide a password, an API endpoint, or a licence key. It only changes readability: the text doubles in size and no information is removed. Use encryption for secrecy, and Base64 when you need something shorter.
This tool handles text only. For images, archives, and binaries, use xxd or hexdump, which also show offsets so you can locate a byte. Pasting a large file into a browser text field will freeze the tab long before it helps.
- No key, so anyone can reverse it in one step
- Twice the size, same information
- Binaries belong in xxd or hexdump, not a browser
FAQ
Why does a Chinese character become e4 b8 ad?
U+4E2D sits in the three-byte range of UTF-8, so it encodes to exactly those bytes. In GBK the same character takes two bytes. Before comparing hex dumps, make sure both sides use the same character encoding.
How is hex different from Base64?
Both are lossless. Hex writes each byte as two characters, doubling the size; Base64 uses 64 symbols and grows by about a third, which suits text protocols better. Hex is easier to read, Base64 is smaller.
Can I use hex as encryption?
No. There is no key and no strength, so anyone can reverse it instantly. Treating hex as encryption is like writing the password on the back of the note. Use real encryption and manage the key properly.
Related tool:Hex Encoder