Text Toolkit

August 14, 2026

Why "word count" isn't as simple as counting spaces

"Just split on spaces and count the pieces" sounds like a complete specification for word counting. It isn't, and the gap between that naive approach and what a real word counter needs to handle is why pasting the same paragraph into two different tools can produce two different numbers, neither of which is wrong.

Hyphenated words: one word, or two?

Take "well-known." Split strictly on whitespace and it's one word, since there's no space inside it. Some style guides and some counting tools instead treat the hyphen itself as a word boundary, splitting "well-known" into two words the same way they'd split "well known." Both are defensible conventions. Whitespace-splitting matches how the word is actually typed and read as a unit; splitting on hyphens matches the fact that "well" and "known" are each independently meaningful words that happen to be joined. There isn't a rule of English that settles this one way for every compound, either, since some hyphenated forms ("e-mail," "check-in") feel more like single words than others ("up-to-date").

Whitespace isn't always one character

A naive splitter that breaks on a single space character produces phantom empty "words" the moment it hits two spaces in a row, a tab, or a line break, because splitting "hello world" on a single space gives ["hello", "", "world"], with an empty string sitting where the second space was. Text pasted from a PDF, an email client, or a double-spaced document is full of exactly this kind of irregular whitespace: multiple consecutive spaces, stray tabs, blank lines used as paragraph breaks. Any word counter that doesn't collapse runs of whitespace into a single separator before splitting will overcount, sometimes substantially, on real-world pasted text, even though the actual number of words a human would count by eye hasn't changed at all.

Punctuation that joins words with no space

An em dash is often typed with no surrounding spaces, as in "the results were clear—nobody expected that." Split purely on whitespace and clear—nobody comes back as a single token, undercounting by one word compared to how a person reading the sentence would count it. The same problem shows up with a slash ("yes/no"), an ellipsis run into the next word, or any other punctuation mark that a writer places directly against a word with no space on either side. A counter that only looks for whitespace boundaries will treat all of these as one word each; a counter that also treats certain punctuation marks as boundaries will count them as two. Neither answer is objectively correct, they're just different tokenization rules applied to the same ambiguous input.

Why Word, Google Docs, and this tool can all disagree

Paste the identical paragraph into Microsoft Word, Google Docs, and a browser-based word counter, and it's entirely normal to get three slightly different counts. Each application made its own decisions about the exact questions above: whether a hyphen splits a word, how runs of whitespace are collapsed, which punctuation marks count as word boundaries, and how numbers, contractions, or standalone symbols get treated. None of these tools are running some canonical, universally agreed-upon word-counting algorithm, because no such standard exists. Word counting is a convention, not a mathematical fact, and every tool that reports a number picked one reasonable convention out of several.

What a reasonable convention looks like in practice

This site's Word Counter counts words as runs of non-whitespace characters, which settles the two most common edge cases in one direction: any stretch of spaces, tabs, or line breaks collapses into a single boundary, so double spaces and blank lines don't create phantom words, and a hyphenated term like "well-known" counts as one word, since there's no whitespace inside it to split on. It's the same convention that trips on the em dash case above: text directly joined by punctuation with no space around it, like clear—nobody, still counts as a single word, because there's genuinely no whitespace there for the split to find. That's a reasonable, defensible convention, not a bug, and it's exactly why the same paragraph can come back with a slightly different number in Word or Google Docs: they made their own reasonable, slightly different choices about the same ambiguous cases.

Want to try it yourself?

Open the Word Counter

Share this guide