A word count is a numerical count of the number of words in a document, file, or string of text. Below are different methods on how to get a word count on a computer.
Word count example
Below is an example of a sentence containing several words. If you had this sentence in a program capable of counting words, it would return "9" as the word count.
In this example sentence, the word count is nine.
Keep in mind that most programs count words by looking for any text separated by spaces in the line. If you had the following example of text, it would also return "9" as the word count.
1 2 3 4 5 6 7 8 9
Getting a word count in a program
There are many programs you may already have installed or can install on your computer to get a word count.
Getting a word count in Microsoft Word
In Microsoft Word, the word count feature is found in the Tools menu or on the Review tab.
The word count feature in Microsoft Word also displays the number of pages, characters (with and without spaces), paragraphs, and lines in the document.
If the Microsoft Word status bar is shown at the bottom, it also shows the document's word count. If the status bar is shown but does not show the word count, right-click the status bar, and make sure that the Word count option has a checkmark.
Count the words in Google Docs
In Google Docs, you can find the word count feature by clicking Tools in the menu bar and select Word count. You can also press the keyboard shortcut Ctrl+Shift+C.
Count the words in WordPerfect
In Corel WordPerfect for Windows, the word count feature is found under Document information in the File menu.
Viewing the word count in Notepad++
In Notepad++, you can find the word count feature by clicking View in the menu bar and selecting Summary.
Viewing word count in TextPad
In TextPad, you can find the word count feature by clicking View in the menu bar and selecting Document Properties. You can also press the keyboard shortcut Alt+Enter.
An example of getting a word count in programming
In computer programming, there are several ways to get a word count of a variable or other text. Below is one example of how you could get a word count of a variable using Perl.
Some programming languages may have a function that calculates and shows a word count.
use strict; my $example = "Hello, this is an example"; my @example = split(/ /, $example);
my $countwords = $#example + 1; print "There are $countwords words in '$example'.\n";
In the example above, we first define the "$example" variable with some generic text as an example. Next, we split that variable by spaces and add each word in to an array. Once the words are loaded to an array, we can count the elements and add one because the count starts as "0" and not "1".
There are five words in 'Hello, this is an example'.
As mentioned earlier, this is one of several ways you could count the words in a file, variable, or other text. The example above, or any other method, could also be made into a subroutine, allowing you to call it throughout the script.
How to View the word count of any text with online tools
There are many online tools to count the number of words in your document. To use an online service, copy any text, and then paste the text into the online tool.
How to get a word count in Linux
In Linux, and other Unix-like operating systems such as macOS, BSD, or WSL, use the wc command to count words.
You can pipe any text to wc (with no options) to view a count of lines, words, and characters in the text:
echo -e "One two three four\n five"
One two three four five
echo -e "One two three four\n five" | wc
2 5 25
Use the -w option to count words only:
echo -e "One two three four\n five" | wc -w
Provide one or more file names to wc to get a count for each file, and display a grand total:
wc -w words.txt words2.txt
5 words.txt 5 words2.txt 10 total
- For more information, see Linux wc command help and examples.
How to do a word count in HTML
Counting the words in HTML can be difficult because of the HTML tags and their contained attributes. For example, counting the words on this page with HTML gives us 3,112 words. However, if we were to remove the HTML, it would reduce the word count to 1,212. Unfortunately, removing HTML tags can also still include text you may not want to be counted.
To count HTML words, open the web page in a browser, highlight and copy the text, and then paste it into a program or online service capable of counting words. With the same text we used above, using this method gave us a word count of 1,082 on this page.
If you need to get the word count of a web page or text on a web page frequently, you can also install a browser add-on designed to get the word count.
Why would someone need to do a word count?
A word count is often needed because a writing project or assignment has a minimum length. For example, when writing a report for school or an article for a web page, it may have a minimum word count of 1,000. Using the word count helps verify you're meeting or exceeding the requirement.