UTF-8 text → bytes
Text to Hex Converter
Encode text as hexadecimal using UTF-8, so nothing outside ASCII gets mangled on the way.
—
—
—
Why UTF-8 rather than ASCII
ASCII can encode 128 characters. UTF-8 can encode every character Unicode defines, which is almost 150,000, while keeping those first 128 identical to ASCII. For plain English text the two produce the same bytes; for anything else, only UTF-8 produces bytes that will decode back to what you typed.
Since UTF-8 is the default for the web, for JSON, for modern source files and for most APIs, encoding as UTF-8 is the right choice unless something specifically demands otherwise.
How the encoding works
- Each character has a Unicode code point — a number identifying it.
- Code points below 128 are written as a single byte, unchanged from ASCII.
- Higher code points are split across two, three or four bytes.
- The leading bits of the first byte declare how many bytes follow, so no separator is needed.
- Each byte becomes two hex digits.
Worked example
café c → U+0063 → 1 byte → 63 a → U+0061 → 1 byte → 61 f → U+0066 → 1 byte → 66 é → U+00E9 → 2 bytes → C3 A9 result → 636166C3A9 — 4 characters, 5 bytes
Four characters, five bytes. That mismatch is the single most important thing to understand about UTF-8, and the reason character count and byte count must never be assumed equal.
Byte cost by script
| Script or type | Bytes each | Example | Hex |
|---|---|---|---|
| ASCII letters, digits, punctuation | 1 | A | 41 |
| Latin accents, Greek, Cyrillic | 2 | é | C3 A9 |
| Hebrew, Arabic | 2 | א | D7 90 |
| Chinese, Japanese, Korean | 3 | 世 | E4 B8 96 |
| Most symbols and arrows | 3 | → | E2 86 92 |
| Emoji | 4 | 😀 | F0 9F 98 80 |
A database column sized in bytes holds far fewer characters than you might expect. A 255-byte field fits 255 English letters, roughly 127 accented ones, 85 Chinese characters or about 63 emoji. Length limits measured in bytes and limits measured in characters are different limits.
Output formats
| Format | Looks like | Used in |
|---|---|---|
| Unbroken | 48656C6C6F | Hashes, protocol fields, database columns |
| Spaced | 48 65 6C 6C 6F | Hex dumps, documentation, packet captures |
| Lower case | 48656c6c6f | Git, hashes, CSS, most modern codebases |
| Upper case | 48656C6C6F | Assembly, hardware docs, memory listings |
Things that quietly change your bytes
If a round trip does not produce the text you started with, the cause is usually one of these rather than the conversion itself.
- Smart quotes. Word processors replace
"with curly quotes, which are three bytes each rather than one. - Line endings. A newline is
0Aon Unix and0D 0Aon Windows. Pasting between systems changes the byte count. - Trailing whitespace. A single trailing space is a real
20byte and will change a hash completely. - Normalisation. An accented letter can be one code point or a letter plus a combining mark. They look identical and encode to different bytes.
Frequently asked questions
How do I convert text to hex?
Encode each character as bytes using UTF-8, then write each byte as two hex digits. For English text that is one byte, and two hex digits, per character.
What is the difference between text to hex and ASCII to hex?
This page encodes as UTF-8 and handles every character. The ASCII converter covers only the 128 ASCII codes. For plain English both produce identical output.
Why is my hex longer than my text?
Every byte becomes two hex digits, and characters outside ASCII take more than one byte. An emoji is four bytes, so eight hex digits.
How many bytes is an emoji in hex?
Four bytes for most emoji, which is eight hex digits. Some emoji are sequences of several code points and take considerably more.
Does a space count as a character?
Yes. Space is byte 20 in hex. So are tabs (09) and newlines (0A).
Why does the same text give different hex elsewhere?
Almost always a different encoding, different line endings, or invisible characters such as smart quotes or a trailing space.