How to convert text to hex
- Type or paste your text. Every language and emoji is supported.
- Choose the character encoding (UTF-8 is the standard), the letter case and how the bytes are separated. Tick New line every 16 bytes for a hex-dump layout.
- Copy the hex string or download it as a text file.
How text is converted to hex
Computers store text as bytes. The converter looks up the byte value of each character in the chosen encoding and writes it as two hex digits. In ASCII and UTF-8, A is 65 = 41, a is 97 = 61 and a space is 32 = 20, so “Hi!” becomes 48 69 21.
| Character | Decimal | Hex |
|---|---|---|
A … Z | 65 … 90 | 41 … 5A |
a … z | 97 … 122 | 61 … 7A |
0 … 9 | 48 … 57 | 30 … 39 |
| Space | 32 | 20 |
! | 33 | 21 |
| New line | 10 | 0A |
UTF-8, Latin-1 and UTF-16 compared
The same character can produce different bytes depending on the encoding. UTF-8 is the right choice for the web, JSON and most files; use another encoding only when the receiving system expects it.
| Text | UTF-8 | Windows-1252 | UTF-16 LE |
|---|---|---|---|
A | 41 | 41 | 41 00 |
é | C3 A9 | E9 | E9 00 |
€ | E2 82 AC | 80 | AC 20 |
| 😀 | F0 9F 98 80 | not available | 3D D8 00 DE |
String to hex in code
- Python:
'Hello'.encode().hex()returns48656c6c6f;.hex(' ')adds spaces. - Node.js:
Buffer.from('Hello').toString('hex') - Browser JavaScript:
[...new TextEncoder().encode('Hello')].map((b) => b.toString(16).padStart(2, '0')).join('') - Linux and macOS:
echo -n 'Hello' | xxd -p
Frequently asked questions
Is text to hex the same as ASCII to hex?
For English letters, digits and punctuation, yes: ASCII and UTF-8 produce the same bytes. Characters such as é, ß, Ж, 中 or emoji are not part of ASCII; UTF-8 encodes each of them as 2–4 bytes.
Why does one character produce several hex bytes?
In UTF-8 only ASCII characters take a single byte. é becomes C3 A9, € becomes E2 82 AC and most emoji take four bytes. Choose UTF-16 or Latin-1 if the target system expects those encodings.
Which separator should I use?
None for hashes and compact strings, spaces for readable hex dumps, colons for MAC addresses and certificate fingerprints, 0x48, 0x65 for arrays in C, C# or Java, and \x48 for string literals in C, Python or shell scripts.
How do I turn the hex back into text?
Press Swap: the hex moves to the input and is decoded with the same encoding. The decoder accepts every separator offered here.