🛠️ToolsShed

Word Frequency Counter

Analyze text and count how often each word appears, ranked by frequency.

Word Frequency Counter analyzes a block of text and tells you how often each word appears, ranked from most to least common. This is a powerful tool for writers, editors, students, and data analysts who need to understand the vocabulary distribution of a document, identify overused words, or perform basic text analysis without specialized software.

Paste your text and the tool tokenizes it into individual words, normalizes case (so "The", "the", and "THE" count as the same word), and displays a frequency table sorted by count. Common stop words (like "the", "a", "is") can be filtered out to focus on the meaningful content words in your text. The results can help you spot repetitive writing patterns that might benefit from synonym variety.

Word frequency analysis has applications beyond writing: in linguistics it underpins readability scores, in marketing it reveals which terms customers use most, and in SEO it helps identify the natural keyword density of content. For academic text analysis, tools like this are a starting point before reaching for more sophisticated NLP libraries.

Frequently Asked Questions

Code Implementation

from collections import Counter
import re

STOP_WORDS = {
    "a", "an", "the", "and", "or", "but", "in", "on", "at", "to",
    "for", "of", "with", "by", "from", "is", "are", "was", "were",
    "it", "this", "that", "be", "as", "not", "i", "you", "he", "she",
}

def word_frequency(text: str, stop_words: bool = True, top_n: int = 10) -> list[tuple[str, int]]:
    # Lowercase and extract words
    words = re.findall(r"[a-z']+", text.lower())
    if stop_words:
        words = [w for w in words if w not in STOP_WORDS]
    counter = Counter(words)
    return counter.most_common(top_n)

text = """To be or not to be, that is the question.
Whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune."""

for word, count in word_frequency(text):
    print(f"{word:<20} {count}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.