Word & Character Counter

Words, lines and three kinds of character count.

Counts

Examples

Questions

Why are there three character counts?

They only agree for plain English. Characters counts what you see, so a family emoji is 1. UTF-16 units is what JavaScript's .length reports. UTF-8 bytes is the size on disk or over the network.

Why is the family emoji 11 UTF-16 units but 1 character?

It's four person emoji joined by three invisible joiners. Each person takes 2 units and each joiner 1, so 4 Γ— 2 + 3 = 11. It's shown as one character.

How are words counted in languages without spaces?

With Intl.Segmenter, which knows word boundaries in Japanese, Thai and other languages. Splitting on spaces would count a whole Japanese sentence as one word.

Does a trailing newline count as a line?

One doesn't: "a\nb\n" is 2 lines, as an editor shows it. A blank line after that does count: "a\nb\n\n" is 3 lines.