Home / Text guides / Guide: how to count words

How to Count Words

Where to find the word count in Word, Google Docs, Pages and Excel, how to count words on the command line and in code, and why different tools give different numbers.

The short answer

The quickest way is an online tool: paste the text into the word counter and read the number. If you work in a document, every major word processor shows the count in the program.

WhereHow
OnlineWord counter
Microsoft WordStatus bar at the bottom, or Review, Word Count. On Windows the shortcut is Ctrl+Shift+G
Google DocsTools, Word count, or Ctrl+Shift+C (Cmd+Shift+C on a Mac)
PagesView, Show Word Count
Excel and Google SheetsFormula that counts the spaces in a cell
Linux and macOSwc -w file.txt
PowerShellGet-Content file.txt | Measure-Object -Word

Microsoft Word

The word count is shown in the status bar at the bottom left. Click it to open a box with pages, words, characters and lines, and an option to include or leave out text boxes, footnotes and endnotes. Select a passage first and the status bar shows the count of the selection as well as the whole document.

Google Docs

Choose Tools, then Word count. The box shows pages, words, characters with and without spaces, and it also has a setting to show the count while you type. It counts the selection if you select text first.

Pages and other programs

In Pages, choose View, then Show Word Count, and the count appears at the bottom of the document. Most editors have a similar status bar counter or an option in the menu, so look for Word count or Statistics.

Excel and Google Sheets

There is no built-in word count function, but you can count the spaces in a cell and add one:

=LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))+1

This gives 1 for an empty cell, so wrap it in an IF test when cells can be empty:

=IF(LEN(TRIM(A1))=0,0,LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))+1)

Command line

# Linux and macOS
wc -w file.txt

# PowerShell
(Get-Content file.txt | Measure-Object -Word).Words

In code

// JavaScript
const words = text.trim().split(/\s+/).filter(Boolean).length;

# Python
words = len(text.split())

// PHP
$words = count(preg_split('/\s+/u', trim($text), -1, PREG_SPLIT_NO_EMPTY));

In PHP, str_word_count is tempting but it can split words with accented letters, so the pattern above is safer for text in many languages.

Why different tools give different counts

  • Hyphenated words. Most tools count well-known as one word, but some split it into two.
  • Standalone symbols. A dash or an ampersand between spaces counts as a word in some programs and not in others.
  • Slashes and em dashes. and/or and word—word are one word or two, depending on the tool.
  • What is included. Footnotes, headers, text boxes and table cells may or may not be in the total.
  • Languages without spaces. Chinese and Japanese need a rule of their own, often one word per character.

The word count tool shows the same text under four rules, so you can see how large the gap is.

Word count targets

If you are writing to a length, the essay word counter compares your count with a target and leaves out citations and references. To turn a word count into a time, use the reading time calculator or the speaking time calculator.

Related tools

Count characters, sentences, paragraphs or lines, check repeated terms with the keyword density checker, or read the guides to character counts, word frequency and counting lines.

Count your words now. Words, characters, sentences, reading time and more, as you type, in your browser.

Open the word counter

Frequently asked questions

How do I check the word count in Word?

Look at the status bar at the bottom left, or choose Review, then Word Count. On Windows, Ctrl+Shift+G opens the same box.

How do I count words in Google Docs?

Choose Tools, then Word count, or press Ctrl+Shift+C (Cmd+Shift+C on a Mac).

How do I count words in Excel?

Count the spaces in the cell and add one: LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))+1. Test for an empty cell first.

Why is the word count different in each program?

Programs differ in how they treat hyphens, symbols, slashes, footnotes and text boxes, so the totals can differ by a few words.