0xCONVERTER-HEX

UTF-8 text → bytes

Text to Hex Converter

Encode text as hexadecimal using UTF-8, so nothing outside ASCII gets mangled on the way.

Text in

Hex

Decimal bytes

Binary

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

  1. Each character has a Unicode code point — a number identifying it.
  2. Code points below 128 are written as a single byte, unchanged from ASCII.
  3. Higher code points are split across two, three or four bytes.
  4. The leading bits of the first byte declare how many bytes follow, so no separator is needed.
  5. 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 typeBytes eachExampleHex
ASCII letters, digits, punctuation1A41
Latin accents, Greek, Cyrillic2éC3 A9
Hebrew, Arabic2אD7 90
Chinese, Japanese, Korean3E4 B8 96
Most symbols and arrows3E2 86 92
Emoji4😀F0 9F 98 80
Practical consequence

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

FormatLooks likeUsed in
Unbroken48656C6C6FHashes, protocol fields, database columns
Spaced48 65 6C 6C 6FHex dumps, documentation, packet captures
Lower case48656c6c6fGit, hashes, CSS, most modern codebases
Upper case48656C6C6FAssembly, 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 0A on Unix and 0D 0A on Windows. Pasting between systems changes the byte count.
  • Trailing whitespace. A single trailing space is a real 20 byte 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.