TXT MetricsEN

Open counting methodology

How Unicode text counting works.

A visible character, a Unicode code point, a JavaScript string unit, and an encoded byte are not the same measurement.

The four lengths answer four different questions

Grapheme clusters

What a person usually perceives as one visible character. TXT Metrics uses this for the main character count.

Code points

The Unicode values that compose text, written like U+1F44D.

UTF-16 units

The units reported by JavaScript string length. Many emoji use more than one.

UTF-8 bytes

The encoded storage or transfer size in UTF-8.

Examples that expose the difference

TextGraphemesCode pointsUTF-16UTF-8
A1111
eฬ1223
๐Ÿ‘๐Ÿฝ1248
๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ171125

The combining-accent example contains two code points but renders as one grapheme. The family emoji uses four emoji plus three zero-width joiners and still appears as one grapheme.

Words depend on language and segmentation rules

Splitting only on spaces fails for Japanese, Chinese, Thai, and other writing systems. The counter uses Intl.Segmenter with the page locale and counts segments marked as word-like. This is more appropriate than a whitespace-only rule, but no automatic word boundary algorithm represents every editorial convention.

Sentence counts, reading time, and speaking time are also estimates. They are presented as supporting metrics rather than universal linguistic facts.

Reproduce the edge cases

The public corpus records inputs and expected grapheme, code point, UTF-16, and UTF-8 totals used by the project. It contains no user text and can be downloaded for testing another counter.