How to use the Word counter tool
- Paste or type your text into the Text box.
- Select Count. Select Example to count a two-line sample.
- Read the five totals in the Result box: Words, Characters, Characters without whitespace, Lines and UTF-8 bytes.
- Edit the text and select Count again to refresh the numbers. Editing clears the old result.
How the word counter decides what a word is
Splitting on spaces fails for text with punctuation, and fails completely for languages written without spaces. This tool instead uses the browser's Intl.Segmenter, which implements the word boundary rules of Unicode Standard Annex 29. It cuts the text into segments and counts only those flagged as word-like, so spaces, commas, dashes and emoji are not words.
The rules have some effects you may not expect. An apostrophe inside a word does not split it, so don't is one word. A hyphen does, so re-run is two. A number with a decimal point such as 3.14 is one word, and a domain such as example.com is one word while user@example.com is two.
The five numbers in the result
Each run prints five lines. They measure different things, and for plain English prose the first three are usually the ones that matter.
- Words: word-like segments, as described above.
- Characters: grapheme clusters, meaning what a reader sees as one character. An emoji built from several code points, or a letter plus a combining accent, counts once.
- Characters without whitespace: the previous count minus spaces, tabs and line breaks.
- Lines: the number of line breaks plus one. A trailing line break therefore adds an empty last line, and empty input reports 0.
- UTF-8 bytes: the size of the text when encoded as UTF-8, which is what most files, APIs and databases store.
Worked example: characters versus bytes
The French phrase below has five words, because the apostrophe in s'il does not split it. It has 30 characters, four of which are spaces. Four letters carry accents and take two bytes each in UTF-8, so the byte count is 34, four more than the character count.
Text: Crème brûlée, s'il vous plaît.
Words: 5
Characters: 30
Characters without whitespace: 26
Lines: 1
UTF-8 bytes: 34Where these counts matter
Limits come in different units, and using the wrong one causes truncated text. Page titles and meta descriptions are judged by visible characters. A database column declared as VARCHAR(255) may count characters or bytes depending on the engine and character set. Cookies, HTTP headers and push notification payloads are limited in bytes. Comparing the Characters line with the UTF-8 bytes line shows at a glance whether your text contains multi-byte characters.
A browser text box stores every line break as a single line feed. If your file uses Windows line endings, its size on disk is one byte per line break larger than the UTF-8 bytes figure shown here.
Frequently asked questions
Does the word counter count hyphenated words as one word?
No. Under the Unicode word boundary rules a hyphen ends a word, so well-known counts as two words and so does e-mail. Contractions joined by an apostrophe, such as it's, count as one.
Why is the character count different from the byte count?
Characters are counted as visible units, while bytes measure storage in UTF-8. ASCII letters take one byte each, accented Latin letters two, most Chinese, Japanese and Korean characters three, and most emoji four or more. Text that is pure ASCII shows identical numbers on both lines.
Are spaces and line breaks counted as characters?
Yes on the Characters line and no on the Characters without whitespace line. Each space, tab and line break is one character. Use the second figure when a limit excludes spaces.
How are emoji counted?
An emoji is not a word, so it adds nothing to Words. It adds one to Characters even when it is built from several code points, such as a family emoji or a flag, and it adds four or more to UTF-8 bytes.
Does it count words in Chinese or Japanese?
It tries to. Those scripts do not put spaces between words, so the browser applies a dictionary to find boundaries, and results can differ slightly between browsers. For these languages a character count is the more common measure.