b2KIT

N-Gram Analyzer

Analyze text for unigrams, bigrams, trigrams, and n-gram frequency distributions with visualization.

Tested tool guide Text and writing tools Checked August 16, 2026

What N-Gram Analyzer does, with a checked example

Paste any block of text and this tool slices it into n-grams: sliding windows of n consecutive words, from single-word unigrams up to the trigram and higher orders you select. Every distinct n-gram is counted, ranked from most to least frequent, and drawn as a bar distribution that shows the shape of your vocabulary at a glance. The surprise for most users: the windows overlap, so n-gram counts are not independent. In 'the cat sat', the token 'the' contributes to the unigram 'the', the bigram 'the cat', and the trigram 'the cat sat' alike. The analysis runs entirely in your browser; nothing is uploaded.

Worked example

A concrete input and expected output from the current implementation.

Input

The cat sat on the mat. The cat sat.

Expected output

Unigrams (9 tokens, 5 unique): the 3; cat 2; sat 2; on 1; mat 1
Bigrams (8 total, 6 unique): the cat 2; cat sat 2; sat on 1; on the 1; the mat 1; mat the 1
Trigrams (7 total, 6 unique): the cat sat 2; cat sat on 1; sat on the 1; on the mat 1; the mat the 1; mat the cat 1

Windows overlap and slide one token at a time, so the 9-token input yields T-n+1 n-grams per order: 9 unigrams, 8 bigrams, 7 trigrams. The phrase 'the cat sat' recurs twice, while the remaining stretch produces distinct singletons. This assumes the tool lowercases and strips punctuation; without case folding, 'The' and 'the' would rank as separate rows.

How the result is produced

1

Tokenization and the sliding window

Text becomes a token stream first: whitespace splits it, and depending on the tool's settings, punctuation is stripped, case is folded, and repeated spaces collapse. The stream is then walked one token at a time, and every group of n consecutive tokens forms one n-gram of order n. A stream of T tokens therefore yields T-n+1 n-grams per order, which is why even a short text produces a long list.

2

Counting, ranking, and the chart

Each unique n-gram accumulates a raw occurrence count, and the table sorts descending, so the distribution's shape appears immediately: a few very frequent n-grams on top and a long tail of singletons, the heavy skew Zipf's law predicts for natural language. The bar chart plots the top ranks of the selected order, with the axis in raw counts or normalized frequency depending on the toggle.

Good uses

  • Editing: run a draft or client document through the trigram view to find formulaic phrasing, such as the same three-word opener repeated across paragraphs, then rewrite for variety.
  • Research: extract the recurring multi-word vocabulary from a pile of product reviews or support tickets to build keyword lists and stop-word lists before any statistical modeling.
  • Style comparison: line up the top bigrams of two texts, such as an original and its translation, and inspect where the phrase patterns diverge or align too closely.

Limits and checks

  • Counts depend on preprocessing. Whether the tool lowercases and strips punctuation decides if 'The' and 'the' merge into one row or rank separately, and whether 'dog. The' becomes a cross-sentence bigram. Read the settings before interpreting the table.
  • Raw counts do not travel across texts. A bigram that occurs twice in a 200-word text is conspicuous; the same count in a 2,000-word text is not. Compare texts only through the normalized frequency view.
  • The rows are not independent observations. Because windows overlap, one token inside the text feeds n different n-grams, and 'cat sat' and 'sat cat' are distinct rows. Summing counts across rows overcounts the underlying words by design.

Common questions

Why are the top n-grams always 'the', 'of', and 'and'?

Frequency ranking is blind to meaning, and function words are simply the most common words in English, so they dominate any n-gram list. The signal distinctive to your text sits lower in the ranking. If the tool offers a stop-word filter, apply it and re-rank; otherwise read past the top rows rather than deleting them.

Is an n-gram the same as a collocation?

No, though they are related. An n-gram is any window of n consecutive words, whether or not the combination is idiomatic: 'the cat' qualifies, and so does 'sat on'. A collocation is an n-gram that occurs far more often than chance and is judged a meaningful unit. This tool reports frequencies; deciding which n-grams are true collocations is a statistical judgment you make afterward.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools