TextEncoder (UTF-8 bytes) Playground

Mrs. Endang’s letter board: every character hung with its UTF-8 bytes, one to four. How many bytes is one emoji, what is its .length, and what happens when…

Why it matters

.length taken for the number of characters is the most common Unicode bug. Byte limits in databases, protocols and SMS, the Content-Length header, and text cut per byte that comes out broken all make sense once UTF-8 shows as chips of bytes.

The key idea

UTF-8 takes 1 to 4 bytes a character, not 1

Try it in this playground