π Count Occurrences of a Word or Phrase in Text
By Shihab Mia Β· Updated 2026-07-03
Enter your text and a word to count, then press Count occurrences.
To count occurrences of a word or phrase, paste your text below, type the term you want to count, and press the button. This word occurrence counter returns the exact total, highlights every match in place, and lists where each one sits in the text. Toggle case sensitivity or whole-word matching to control what counts. Everything runs in your browser, so your text is never uploaded anywhere.
What is the Word Occurrence Counter?
Counting how often a specific word appears is a deceptively common task. Writers check whether they have overused a phrase, students count keyword mentions in an essay, SEO editors measure how often a target term appears on a page, and developers tally occurrences of a token in logs or code. Doing it by eye is slow and unreliable past a handful of matches, so a tool that scans the whole text at once and reports an exact number removes the guesswork. That is exactly what this counter does: it lets you count occurrences of any term in one pass, no matter how long the text.
Two settings decide what actually counts as a match. Case sensitivity controls whether capitalisation matters: with case-insensitive matching on, a search for "data" also catches "Data" and "DATA", which is usually what you want when you count occurrences of a concept regardless of where it sits in a sentence. Whole-word matching decides whether the term must stand alone. With it off, searching "cat" also counts the "cat" inside "category" and "scatter". With it on, only the standalone word cat is counted, because the match must sit between word boundaries. Most other counters force one behaviour on you, but here both toggles are in your hands.
The term you type is treated as literal text, not a search pattern. Characters such as a dot, dollar sign, asterisk, or bracket normally carry special meaning in pattern matching, so the tool escapes them automatically. That means searching for "a.b" counts the literal sequence "a.b" and not "axb", and searching for "$5" counts the literal "$5". This keeps the result predictable: what you type is exactly what gets counted, whether it is a single word, a phrase with spaces, or a string with punctuation.
Matches are counted without overlap, scanning left to right. This matters for repeating patterns. If you count occurrences of "aa" inside "aaaa", the tool finds two non-overlapping matches at positions 1 and 3, not three overlapping ones. Non-overlapping counting is the standard behaviour of nearly every find-and-replace and word frequency counter, so the number you get here lines up with what your editor, spreadsheet, or programming language would report for the same term.
Alongside the raw total, the tool reports density: the share of the total word count made up by your search term. Density is what SEO editors watch when they want a keyword present but not stuffed, and it is what a teacher might use to see how heavily a student leans on one word. Because the counter shows the count, the density, the exact positions, and the highlighted text together, you can both count occurrences and understand the context of each one without scrolling back and forth. Nothing is sent to a server, so even a confidential draft, a client contract, or a private log stays entirely on your device.
When to use it
- Checking how many times a keyword appears in an article before publishing, and reading its density.
- Counting mentions of a brand, product, or person across a long document or report.
- Verifying you have not overused a filler word or crutch phrase in your writing.
- Tallying how often a specific token, error code, or file path shows up in pasted logs.
- Confirming a legal or academic term is used consistently and the right number of times.
- Measuring keyword frequency and density for on-page SEO without a paid tool.
How to use the Word Occurrence Counter
- Paste or type your text into the large text box.
- Enter the word or phrase you want to count in the search field.
- Toggle Case-insensitive on or off depending on whether capitalisation should matter.
- Toggle Match whole word only to exclude matches that sit inside larger words.
- Press Count occurrences to see the total, the density, the highlighted matches, and each match position.
Formula & method
Worked examples
Count occurrences of "the" in "The cat sat on the mat" with case-insensitive matching on.
- Search term = the
- Case-insensitive on, so "The" and "the" both count
- Matches found: "The" at the start and "the" before mat
- Total = 2
Result: 2 occurrences of "the"
Count whole-word "cat" in "a cat in a category with cats" so only the standalone word counts.
- Search term = cat, Match whole word only on
- The standalone word "cat" counts
- "category" and "cats" are not whole-word matches, so they are skipped
- Total = 1
Result: 1 occurrence of whole-word "cat"
Count the phrase "data set" in a 100-word paragraph where it appears 4 times, and read the density.
- Search term = data set (a two-word phrase)
- The space is part of the literal term
- Each of the 4 appearances counts as one match
- Density = 4 / 100 x 100 = 4.0%
Result: 4 occurrences, 4.0% of total words
What each option does
| Option | Effect when on | Effect when off |
|---|---|---|
| Case-insensitive | Ignores upper and lower case (data = Data = DATA) | Counts only the exact case you typed |
| Match whole word only | Counts standalone words only (cat, not category) | Counts the term anywhere, even inside larger words |
Example counts for the term "is" in different settings
| Text | Settings | Count |
|---|---|---|
| This is his list | Whole word off, case-insensitive on | 4 (this, is, his, list) |
| This is his list | Whole word on, case-insensitive on | 1 (is) |
| Is it? It is. | Whole word on, case-insensitive off | 1 (the lowercase is) |
| Is it? It is. | Whole word on, case-insensitive on | 2 (Is, is) |
Keyword density guide (rough SEO reference, not a rule)
| Density | Reading | Typical action |
|---|---|---|
| 0% | Keyword missing from the page | Add the term naturally where relevant |
| 0.5% to 2% | Healthy, natural usage | Usually fine, leave as is |
| Above 3% | Risk of keyword stuffing | Reword some mentions or add more content |
Common mistakes to avoid
- Forgetting that partial matches count by default. With whole-word matching off, counting "art" also counts the "art" inside "part", "smart", and "started". Turn on Match whole word only when you mean the standalone word.
- Missing capitalised matches. If you turn case-insensitive off, a search for "monday" will not count "Monday". Keep case-insensitive on when capitalisation should not matter, which is the default here.
- Including stray spaces in the search term. A trailing or leading space is part of the literal term, so searching "cat " (with a space) will not match "cat" at the end of a sentence. Type the term without extra spaces unless you mean to include them.
- Expecting wildcards or patterns to work. The term is matched as literal text, so symbols like a dot or asterisk count those exact characters, not a pattern. This is intentional and keeps the count predictable.
- Assuming overlapping repeats are all counted. Counting "aa" in "aaaa" returns 2, not 3, because matches do not overlap. This matches how find-and-replace works in editors and spreadsheets.
- Reading density as a hard SEO target. Keyword density is a rough signal, not a rule search engines enforce. Aim for natural writing rather than hitting a specific percentage, and treat any figure above roughly 3% as a prompt to reword.
Glossary
- Occurrence
- A single place in the text where the search term appears, according to your case and whole-word settings.
- Case-insensitive
- A search mode that treats upper and lower case as the same, so "Text" and "text" both count.
- Whole word
- A match that stands alone between word boundaries, so "cat" counts only the word cat and not parts of other words.
- Word boundary
- The edge between a word character (letter, digit, underscore) and a non-word character such as a space or punctuation mark.
- Density
- The share of the total word count made up by your search term, shown as a percentage.
- Literal match
- Matching the exact characters you typed, with no special or wildcard meaning applied to symbols.
- Non-overlapping
- A counting method where each matched section of text is used once, so repeats like "aa" in "aaaa" count as 2.
- Term frequency
- The raw number of times a word or phrase appears in a body of text, the core output of this counter.
Frequently asked questions
How do I count how many times a word appears in text?
Paste your text into the box, type the word in the search field, and press Count occurrences. The tool shows the total count, highlights every match, and lists the position of each one.
Can I count a phrase, not just a single word?
Yes. Type the full phrase, spaces and all, into the search field. The phrase is matched as a literal string, so each exact appearance is counted as one occurrence.
Does the counter ignore upper and lower case?
By default it does, because case-insensitive matching is on. With it on, "data", "Data", and "DATA" all count toward the same total. Turn it off to count only the exact case you typed.
What does Match whole word only do?
It counts the term only when it stands alone, so counting "cat" will not include the "cat" inside "category" or "scatter". Leave it off if you want to count the term anywhere it appears, including inside larger words.
Can I search for terms with punctuation or symbols?
Yes. Characters like a dot, dollar sign, or bracket are treated as literal text and escaped automatically, so searching for "a.b" or "$5" counts those exact sequences rather than acting as a pattern.
How are overlapping repeats counted?
Matches do not overlap. Counting "aa" in "aaaa" returns 2, not 3, because the scan moves past each match before looking for the next. This is the same behaviour as find-and-replace in most editors.
What is keyword density and why does the tool show it?
Density is your count divided by the total number of words, shown as a percentage. It helps SEO editors and writers see how heavily a term is used. A rough natural range is about 0.5% to 2%; above 3% often reads as keyword stuffing.
Can I count occurrences in a very long document?
Yes. The counter scans the whole text in one pass, so it handles long articles, transcripts, and log files quickly. There is no length limit imposed by the tool beyond what your browser can hold in memory.
Does the tool count matches that span across line breaks?
A phrase is matched as the exact characters you type. If your phrase does not include a line break but the text has one between the words, that spot will not match. Paste the text as continuous lines if you want those cases counted.
Is my text uploaded or stored anywhere?
No. All counting happens in your browser using plain JavaScript. Your text never leaves your device and nothing is sent to a server, so it is safe for private or confidential content.