What is UTF-8?

UTF-8 is the encoding behind almost all modern text. It stores each Unicode code point in 1 to 4 bytes, staying compact for common characters while covering every emoji and script.

How it works

UTF-8 is variable-width. ASCII characters (A–Z, digits, common punctuation) take 1 byte and are byte-for-byte identical to old ASCII. Accented letters and most scripts take 2–3 bytes; emoji and rarer characters take 4. The leading bits of each byte signal how many bytes the character spans.

Why it's brilliant

  • Backward-compatible with ASCII — old English text “just works.”
  • Compact for the most common characters.
  • No byte-order ambiguity (unlike UTF-16).
  • Self-synchronizing — you can find character boundaries easily.

Declaring it

On the web, declare it early in your HTML so the browser decodes text correctly:

<meta charset="utf-8">

Frequently asked questions

Is UTF-8 the same as Unicode?

No — Unicode is the character set (the numbers); UTF-8 is one way to encode those numbers as bytes.

How many bytes is an emoji in UTF-8?

Most emoji take 4 bytes in UTF-8; some sequences (like flags or skin tones) take several times that.