UTF-8 Explained: Why One Chinese Character Counts as 3 Bytes
How UTF-8 encodes ASCII, Latin accents, CJK and emoji: byte lengths per code point, why string length disagrees across systems and how to inspect any character.
Every developer eventually hits the wall: a string that counts differently in the database, in JavaScript and in the API payload. The culprit is almost always the gap between characters, code points and bytes.
The three layers: characters, code points, bytes
A character is what a human reads. A code point is its number in the Unicode table (U+4F60 for the word ni in Chinese). A byte is what storage actually holds after UTF-8 encoding. UTF-8 uses 1 byte for ASCII, 2 bytes for most Latin accents, 3 bytes for CJK and 4 bytes for emoji.
That is why one Chinese character counts as a single character and 3 bytes — and why an emoji counts as one character, 4 bytes and two UTF-16 units in engines using surrogate pairs.
Where the counts disagree
- Databases: VARCHAR(10) may mean 10 bytes or 10 characters depending on charset and engine.
- JavaScript: .length counts UTF-16 units, so an emoji is 2.
- Limits and billing: APIs that cap by bytes silently truncate multibyte text mid-character.
The Word Counter shows characters, code points and byte columns side by side, so you can see which limit actually applies to your text.
Debugging invisible characters
Copy-pasted text often drags zero-width joiners (U+200D), BOM marks (U+FEFF) or soft hyphens (U+00AD) that match nothing in your source code and break string comparisons silently. Paste the string into the Unicode Converter and every code point appears with its name — invisible ones light up instantly.
The rule of thumb
When a limit or a length matters, always ask which unit it uses: characters, code points, UTF-16 units or bytes. The Unicode inspector answers that question for any single character in seconds, fully offline.
Related guides
Base64 vs Hex Encoding: When to Use Each (Developer Guide)
Base64 vs hex encoding compared: size overhead, readability, common use cases in JWTs, data URLs and git diffs — with a quick decision table for engineers.
Read guide →2026-10-11How to Decode a JWT: Reading Header, Payload and Signature
Decode any JWT by hand or with a browser tool: how the three parts are encoded, which claims matter (sub, exp, iss, aud) and why decoding is not verification.
Read guide →2026-10-09Cron Expressions: A Field-by-Field Guide with Real Examples
Read and write cron like a native: what the 5 fields mean, steps and ranges, the day-of-month vs day-of-week rule, @daily shorthands and timezone pitfalls.
Read guide →Try these tools
Unicode Converter
Convert any text to \uXXXX JavaScript escapes, U+XXXX code-point lists, 0x hex or numeric entities — and paste escapes back to readable text. Emoji and surrogate pairs handled correctly.
Open tool →Word Counter
Live word, character, sentence and paragraph statistics plus reading-time estimates. Works offline on any text — no length limits, nothing uploaded.
Open tool →Base64 Encoder / Decoder
Encode text to Base64 or decode it back in one click, plus image ⇄ Base64 data-URL conversion with drag & drop. Free, instant and 100% browser-based — nothing is uploaded.
Open tool →