⌘K

Developer

UTF-8

UTF-8 is a variable-width Unicode encoding that represents every character in one to four bytes and is fully backwards compatible with ASCII.

Updated 12 Aug 2026

One encoding for every language

UTF-8 encodes Unicode code points using between one and four bytes. Code points below 128 use a single byte identical to ASCII, so every ASCII file is already valid UTF-8. Higher code points use lead bytes that announce the sequence length, followed by continuation bytes.

RangeBytesExample
U+0000–U+007F1A, 9, newline
U+0080–U+07FF2é, ß, Ω
U+0800–U+FFFF3€, 中, ह
U+10000–U+10FFFF4emoji, rare scripts

Why it won

  • No wasted space for English or markup-heavy content
  • Self-synchronising — a parser can find character boundaries from any position
  • No byte-order ambiguity, unlike UTF-16 and UTF-32
  • Existing ASCII tooling keeps working unchanged

Because characters vary in width, count code points or grapheme clusters rather than bytes when limiting input length — otherwise a name with an emoji can be truncated mid-character.

Base64 Encoder

Encode text to inspect the exact bytes a character produces.

Try Base64 Encoder

Characteristics

  • Variable width: one to four bytes per character
  • Superset of ASCII for the first 128 code points
  • Self-synchronising and byte-order independent
  • Default encoding for HTML, JSON and most modern APIs

Common uses

  • Web pages, JSON payloads and source files
  • Database storage of multilingual text
  • Filenames and log output on modern operating systems
  • Any interchange format where language coverage matters

Advantages

  • Complete Unicode coverage in a single scheme
  • Compact for Latin script and structured text
  • Compatible with the huge base of ASCII-oriented tooling
  • No endianness problems

Limitations

  • Less compact than UTF-16 for East Asian text
  • Random access by index requires scanning
  • Invalid byte sequences must be handled explicitly
  • String length in bytes rarely matches what users perceive

Examples

Byte counts for a mixed-script string
"Hi €5 😀"
H  -> 48            (1 byte)
€  -> E2 82 AC      (3 bytes)
😀 -> F0 9F 98 80   (4 bytes)

Frequently asked questions

What is UTF-8 used for?

Encoding text for the web, files, databases and APIs so any language can be represented reliably.

Is ASCII valid UTF-8?

Yes. The first 128 code points are byte-identical, so every ASCII file is already UTF-8.

UTF-8 or UTF-16?

UTF-8 for interchange and storage. UTF-16 only appears in specific runtimes such as Java and JavaScript strings in memory.

How many bytes is an emoji?

Usually four, and composite emoji made of several code points can be considerably more.

Does UTF-8 need a byte-order mark?

No. It has no byte-order ambiguity, and the mark can confuse parsers.

Related terms

All terms

Related tools

Related guides

All guides