Utility Tools

Why Character Counts and UTF-8 Byte Counts Differ

The Boring Tools character counter displays several measurements of the same text. Its character count uses JavaScript string length, while its byte count uses UTF-8 encoding. The difference matters for emoji, Japanese text, and systems that impose storage limits.

Worked examples from the counter's implementation

| Text | Character count (UTF-16 code units) | UTF-8 bytes | | --- | --- | --- | | hello | 5 | 5 | | hello world | 11 | 11 | | こんにちは | 5 | 15 | | 😀 | 2 | 4 |

JavaScript stores strings as UTF-16 code units. A basic Latin letter takes one unit; the emoji in the last row takes two. UTF-8 encodes the Japanese characters in this example using three bytes each. The counter uses text.length and new TextEncoder().encode(text).length for these two measurements.

These are measurements of the text in the input field, not of a saved document. A file may contain a byte-order mark, different line endings, or formatting that changes its size.

A visible character can contain several units

Some symbols combine a base letter with an accent, a skin-tone modifier, or multiple emoji joined together. They can look like one character while containing several code points and UTF-16 units. This tool does not count grapheme clusters, so do not assume its character total equals the number of visible symbols.

For implementation details, consult the JavaScript string length reference and the TextEncoder reference.

How words and line breaks are counted

The word count trims the input, then separates it at whitespace. hello world counts as two words. A Japanese sentence without spaces counts as one segment under this rule; it is not linguistic word segmentation.

The newline count counts line-feed characters in the input. A line that wraps visually because the input field is narrow does not add a newline. Spaces and newline characters are included in the character total.

Choose the measurement your destination requires

Use bytes for a UTF-8 byte limit and the destination's own validation for platform-specific character or word limits. If you need help preparing a draft, follow the submission checklist. A measured length alone does not describe readability, writing quality, or search ranking.