UTF-8 vs UTF-16: Key Differences, Size & Uses Explained

UTF-8 vs UTF-16 comes down to one simple question. How does a computer turn a Unicode number into real bytes? Both formats can represent the same Unicode characters. Unicode defines the code points. UTF-8 and UTF-16 are two different encoding forms used to represent those code points as code units.

This choice can affect file size and how software handles text. This guide explains how each format works, where UTF-32 fits in, and which one actually matters for your situation.

What Encoding Actually Means

A code point is a number. It identifies a character. Encoding is a separate step. It turns that code point into code units that can be stored or transmitted.

Unicode defines the code points. It does not require one single way to encode them as bytes. UTF-8, UTF-16, and UTF-32 are Unicode encoding forms. This means the same character can be represented by different sequences of bytes or code units, depending on the encoding. Both encodings still represent the same Unicode character, as explained in a guide to what Unicode actually is.

Think about money. Ten dollars can be one ten-dollar bill, or it can be two five-dollar bills. Both equal the same amount. They just look different. A Unicode code point works in a similar way. The code point stays the same, but the encoded bytes or code units can be different.

How UTF-8 Works

UTF-8 encodes each Unicode scalar value using one to four bytes. Basic ASCII characters only need one byte. Other characters need more bytes. The first 128 Unicode code points match ASCII, so those characters use the same single-byte values in UTF-8.

Character TypeBytes in UTF-8Example
Basic English letters and numbers1 byteA
Many European accented letters2 bytesé
Many characters from Asian scripts3 bytesCommon CJK characters
Emoji and other supplementary characters4 bytesMany emoji

This design is called variable-length encoding. It uses fewer bytes for ASCII text while supporting the full Unicode range. UTF-8 is also widely used for text on the web.

How UTF-16 Works

UTF-16 uses one 16-bit code unit for characters that fit within its single-unit range. Characters outside that range use two 16-bit code units. These two units together are called a surrogate pair.

Unicode has more characters than can fit into a single 16-bit value. UTF-16 handles the additional characters with surrogate pairs. When software reads a valid pair, it interprets the two code units as one Unicode character. (unicode.org)

Some programming languages and software systems use UTF-16 internally. A program can work with text internally using UTF-16 and later save or send that text using another encoding.

A letter with an accent mark can also be represented in more than one Unicode form. It can sometimes be represented by one precomposed character or by a base character followed by a combining mark. This detail is explained fully in a guide to Unicode normalization, and the chosen representation can affect how many code units an encoding needs.

UTF-32 in Brief

UTF-32 takes the simplest approach. Each Unicode scalar value uses exactly four bytes.

This fixed size can make some internal text-processing tasks easier. However, it uses more space for many types of text than UTF-8 or UTF-16. Because of this, UTF-32 is less common for storing or transmitting everyday text.

The Practical Difference That Actually Matters

Most of the time, the choice depends on where the text is being used. UTF-8 is widely used on the web and is recommended by the W3C for HTML documents. It is also efficient for text that contains many ASCII characters.

UTF-16 still matters in software systems that use it internally or require it for compatibility. If you are building something new for the web today, UTF-8 is generally the practical choice.

A character like Zero Width Space needs three bytes in UTF-8. Its lack of visible width does not affect its encoded size. The number of bytes depends on its Unicode code point and the encoding being used.

UTF-8 vs UTF-16: Frequently Asked Questions

Which encoding does the web mostly use today?

UTF-8 is widely used across the modern web. It is also recommended by the W3C for HTML documents. (w3.org)

Is UTF-8 always smaller than UTF-16?

No. It depends on the characters in the text. ASCII characters use one byte in UTF-8 but two bytes in UTF-16. Some characters use three bytes in UTF-8 but only one 16-bit code unit in UTF-16. Supplementary characters use four bytes in UTF-8 and two 16-bit code units in UTF-16.

What is a surrogate pair in UTF-16?

It is a pair of two 16-bit code units that together represent one Unicode character outside UTF-16’s single-code-unit range. UTF-16 uses surrogate pairs for supplementary characters, including many emoji.

Can UTF-8 and UTF-16 show different characters?

No, not when they are decoded correctly. Both are Unicode encoding forms and can represent the same Unicode scalar values. The difference is how those values are encoded.

Why do old files show garbled text today?

This usually happens when text is decoded using the wrong character encoding. The stored bytes may be correct, but the software interprets them using different encoding rules.

Is UTF-32 ever a good choice?

It can make some internal text-processing tasks simpler because every Unicode scalar value uses four bytes. Its larger size makes it less practical for many storage and transmission tasks.

Does my encoding choice affect emoji?

Yes, it affects how emoji are represented in memory or storage. UTF-16 uses a surrogate pair for supplementary emoji characters, while UTF-8 generally uses four bytes for the same Unicode character.