Home › Text Tools › N-Gram Generator

N-Gram Generator

Split any text into word or character n-grams, from single words to five-word phrases, and see how often each one appears. Filter out stopwords, set a minimum count, and export the full frequency table as CSV.

Last updated:

N-gram type
#N-gramCountShare

Advertisement
Advertisement

How to use the N-Gram Generator

  1. Paste your text or press Load sample.
  2. Choose Words or Characters and the gram size N, for example 2 for bigrams or 3 for trigrams.
  3. Set filters: stopwords, minimum count, case and punctuation handling, and whether n-grams may cross sentences.
  4. Press Generate n-grams to refresh the frequency table and top-15 chart (it also updates as you type).
  5. Export the full list with Download CSV, or Copy table to paste into Excel or Google Sheets.

How n-grams are counted

The text is split into tokens (words, or characters), then a window of size n slides along one token at a time. Each window is one n-gram. For a sentence with T tokens:

Number of n-grams = T − n + 1 (zero when T < n)

Share of an n-gram = count ÷ total n-grams × 100%

Example with the sentence "the cat sat on the mat" (T = 6 words):

NNameCount (6 − n + 1)N-grams
1Unigram6the, cat, sat, on, the, mat ("the" appears twice)
2Bigram5the cat, cat sat, sat on, on the, the mat
3Trigram4the cat sat, cat sat on, sat on the, on the mat
44-gram3the cat sat on, cat sat on the, sat on the mat
55-gram2the cat sat on the, cat sat on the mat

Common uses

  • SEO and keyword research: find the two- and three-word phrases a page or a competitor's content repeats most.
  • Review and survey analysis: bigrams like "fast shipping" or "poor quality" summarise what customers say.
  • Writing and editing: spot overused phrases and repetitive sentence openings.
  • Language modelling and NLP classes: n-gram counts give the probabilities P(word | previous n − 1 words) ≈ count(n-gram) ÷ count(prefix).
  • Character n-grams: language detection, fuzzy matching and spelling suggestions.

For single-word frequencies with charts, the Word Frequency Counter is a simpler alternative; for SEO density percentages, try the Keyword Density Checker.

Frequently asked questions

What is an n-gram?

An n-gram is a sequence of n consecutive items from a text. With words, 'machine learning model' contains two bigrams (machine learning, learning model) and one trigram. With characters, the word 'text' contains the character bigrams te, ex and xt. N-grams are a basic building block of language models, search engines, spell checkers and keyword research.

How many n-grams does a text have?

A sequence of T tokens has T − n + 1 n-grams of size n (or none if T is smaller than n). For example, 10 words give 9 bigrams and 8 trigrams. When 'Don't cross sentence boundaries' is on, the formula is applied to each sentence separately, so the total is slightly lower.

What does the stopword filter do?

Stopwords are very common words such as the, of, and, is and to. Dropping n-grams that start or end with a stopword removes fragments like 'of the' or 'the customer' while keeping meaningful phrases like 'easy to use'. You can also drop only n-grams made entirely of stopwords, drop any n-gram containing one, or keep everything.

How is the Share column calculated?

Share is the count of that n-gram divided by the total number of n-grams of the same size in the text, before stopword or minimum-count filtering, times 100. It is the relative frequency, which is the maximum-likelihood probability estimate used in simple n-gram language models.

When should I use character n-grams?

Character n-grams are useful for language identification, fuzzy matching, spelling correction, cryptography exercises and analysing letter combinations. Turn on 'Include spaces' to let n-grams span word boundaries; spaces are shown as ␣.

Is there a size limit?

There is no fixed limit; everything runs in your browser's memory. Texts of several hundred thousand words work on a modern computer, though the table shows the top rows only. The CSV always contains every n-gram that passes the filters.

Is my text uploaded?

No. All counting happens locally in JavaScript. The text is only remembered in your browser's local storage so it is still there when you come back.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Word Frequency CounterFind the most used words and phrases in any text and turn them into a word cloud.Keyword Density CheckerFind the most used 1, 2 and 3-word phrases in your text and their keyword density %.Word CounterCount words and characters and clean up text.Readability CheckerScore your text with Flesch, Flesch-Kincaid, Gunning Fog, SMOG and more readability tests.Character CounterCount characters with and without spaces, words, lines and bytes, with live limit bars.Grammar CheckerCheck grammar, spelling and punctuation with clickable suggestions and one-click fixes.Word Count to PagesHow many pages is 1,000 words? Estimate pages by font, size, spacing and margins.X Post Character CounterCount X (Twitter) post characters and split long text into a thread.YouTube Title Length CheckerCheck YouTube title length, preview truncation and score it for clicks.Text CompareFind the differences between two texts.Sentence CounterCount sentences and paragraphs, see average sentence length and spot long sentences.Reading Time CalculatorEstimate how long a text takes to read or speak at any speed, and copy a “5 min read” badge.Palindrome CheckerCheck if a word, sentence or number is a palindrome and find the longest palindrome in text.Syllable CounterCount syllables per word, line and total, and check haiku 5-7-5 instantly.Text SummarizerSummarize long text into its key sentences and keywords, privately in your browser.Spell CheckerCheck spelling online: misspelled words are highlighted with suggestions you can click to fix.DictionaryLook up English word definitions with pronunciation audio, examples, synonyms and antonyms.Letter Frequency CounterCount how often each letter appears, compare with English frequencies and see top bigrams.Antonym FinderFind opposites of any word: direct antonyms, near antonyms and definitions, click to copy.British to American Spelling ConverterConvert UK spelling to US spelling and back (colour/color, organise/organize) with highlights.Homophone FinderLook up homophones like there/their/they're with definitions and examples from 400+ sets.Passive Voice CheckerHighlight passive voice in your writing, see the passive sentence %, and get active rewrites.Periodic Table Word SpellerSpell words and names with chemical element symbols and download them as element tiles.Related Words FinderFind words related to any word or topic: associations, describing adjectives and more.Synonym FinderFind synonyms grouped by relevance, filter by syllables or first letter and click to copy.Text Similarity CheckerCompare two texts for similarity with cosine, Jaccard and Levenshtein scores and shared phrases.Words That Start With FinderFind words that start with, end with or contain any letters, filtered by length.AI Token CounterCount GPT tokens in any text, see every token highlighted and estimate the API input cost.Elevator Pitch GeneratorBuild 10, 30 and 60-second elevator pitches with word counts and speaking time.Abbreviation FinderLook up what common abbreviations and acronyms stand for, or find the abbreviation for a phrase.Describing Words FinderEnter a noun and get adjectives that commonly describe it, sorted by how often they are used.Keyword ExtractorPull the top keywords and key phrases from any text with RAKE or TF-IDF scores.Line CounterCount total, non-empty, blank and unique lines in text or a .txt file, with line length stats.Paragraph CounterCount paragraphs in any text, with words and sentences per paragraph and the longest and shortest.Resume Keyword ScannerCompare your resume to a job description: match score, missing skills and keyword counts.Scrabble Word CheckerCheck if a word is playable, see its Scrabble score, hooks, anagrams and two-letter word meanings.Sentiment AnalyzerScore the sentiment of reviews and messages per sentence, with positive and negative words.SMS Character CounterCount SMS characters and segments, detect GSM-7 vs Unicode and find the characters that cost extra.Spelling Test GeneratorTurn a word list into a spoken, auto-graded spelling test or a printable test with answer key.Transition Words FinderFind transition words by category with examples, and check the transitions in your essay.Writing Style AnalyzerHighlight hard sentences, adverbs, passive voice and complex words, with a grade level.Food Allergen CheckerPaste an ingredient list to highlight the 9 major food allergens and their hidden names.GC Content CalculatorDNA/RNA GC %, AT %, base counts, GC skew and a sliding-window GC plot from any sequence or FASTA.Google Ads Character CounterWrite responsive search ads with live 30/90/15 counters, pins, keyword insertion checks and a preview.ORF FinderFind open reading frames in all 6 frames of a DNA sequence, with positions, lengths and protein translations.Podcast Intro Script GeneratorWrite podcast intro and outro scripts in five tones, with sponsor, call to action and read time.Restriction Enzyme FinderFind cut sites for 180+ restriction enzymes in DNA, with fragment sizes, a site map and a virtual gel.SAT Vocabulary Flashcards363 high-frequency SAT words with definitions and examples: flip cards, quizzes and saved progress.Text HighlighterHighlight chosen words and phrases in several colors, count each one and copy the colored text.Social Media Character CounterCheck one post against X, Instagram, TikTok, LinkedIn, YouTube and more limits at once.Spelling Bee SolverEnter the 7 honeycomb letters to get every word, pangrams highlighted, points and a hint grid.Spelling PracticeType your weekly spelling words, hear each one read aloud, spell it and retry the misses.
See all 53 Text Counters & Analyzers →