UTF-8 Encode

Show the UTF-8 bytes behind any text as escaped hex, so you can see how each character is stored.

Text
UTF-8 bytes
Runs locally in your browser

About the UTF-8 Encode

UTF-8 encodes each Unicode character as one to four bytes: ASCII characters take one byte, most Latin and accented letters two, most other scripts three, and emoji four. This tool shows those bytes as \xNN escapes, which makes visible why a string's byte length differs from its character length, a frequent source of off-by-one bugs in databases and APIs with byte limits.

The byte count follows the code points, not the glyphs you see on screen. An é stored as the single code point U+00E9 takes two bytes, while the same letter written as a plain e plus a combining acute accent takes three, so two visually identical strings can measure differently. Emoji make the gap wider: one glyph with a skin-tone or flag modifier is a sequence of several code points and can run past twenty bytes, which is how a nickname that looks ten characters long overflows a varchar(20).

Seeing the encoding is useful when debugging mojibake (text decoded with the wrong encoding), when a field has a byte limit rather than a character limit, or when learning how Unicode and UTF-8 relate. The UTF-8 Decode tool turns the byte escapes back into text, Unicode Escape shows the code points instead of the bytes, and Unicode Code Point Finder lists them one line per character.

How to use

  1. Paste text on the left.
  2. Read the byte escapes on the right.
  3. Count the bytes to check against a field limit.

Common questions

Why does one emoji show four bytes?
Characters outside the Basic Multilingual Plane, including most emoji, take four bytes in UTF-8.
How is this different from Unicode Escape?
Unicode Escape shows code points (\uXXXX); this shows the UTF-8 bytes (\xNN), which is what is actually stored and transmitted.
Can I decode it back?
Yes, with the UTF-8 Decode tool.