N-Gram Extractor

Extract and analyze word and character n-grams (unigrams, bigrams, trigrams, 4-grams, 5-grams) with frequency counts, percentages, and diversity metrics.

Updated

Share:

Input Text

0 characters

Options

Total N-grams

0

Unique N-grams

0

Diversity Ratio

0.0%

N-gram Table
word-2gram

Enter text above to extract n-grams.

Frequently Asked Questions

What is an n-gram?

A contiguous sequence of n items (words or characters). Unigrams = single words, bigrams = pairs, trigrams = triples. N-grams are foundational to NLP and language modeling.

Word vs character n-grams?

Word n-grams are sequences of words ("machine learning" is a word bigram). Character n-grams are character sequences — especially useful for language detection and fuzzy matching.

What is the diversity ratio?

Type-token ratio — the percentage of unique n-grams relative to total. Higher = more lexical variety; lower = repetition. A classic measure in corpus linguistics.

Is the N-Gram Extractor free to use?

Yes, the N-Gram Extractor is 100% free with no registration, no hidden fees, and no usage limits. All processing happens locally in your browser, ensuring complete privacy.

Is my data safe with this tool?

Absolutely. The N-Gram Extractor processes everything client-side in your browser. No data is uploaded to or stored on any server. Your content remains private on your device at all times.

Does the N-Gram Extractor work on mobile devices?

Yes, the N-Gram Extractor is fully responsive and works on smartphones and tablets. You can use it on any device with a modern web browser -- no app download required.

Do I need to create an account to use this tool?

No account or registration is needed. Simply open the N-Gram Extractor in your browser and start using it immediately. There are no sign-up walls or usage restrictions.

Can I process large amounts of text?

Yes, the N-Gram Extractor handles text of any length with fast, real-time processing. Since everything runs in your browser, performance depends on your device but works well for most use cases.

How do I use the N-Gram Extractor?

Simply enter your input in the provided field, adjust any settings to your preference, and the tool will process it instantly. You can then copy the result to your clipboard or download it.

Which browsers are supported?

The N-Gram Extractor works in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. For the best experience, use the latest version of your preferred browser.

Why should I remove stop words before extracting n-grams?

Stop words are common function words like "the", "of", "and", and "to" that appear constantly but carry little meaning. If you leave them in, your top bigrams and trigrams fill up with combinations like "of the" and "in the" that drown out the phrases you actually care about. Turning on the remove stop words option drops these tokens before counting, so meaningful sequences such as "natural language processing" rise to the top of the ranking. This is especially useful for SEO keyword analysis and theme detection, where you want the substantive phrases, not the grammatical glue. For raw linguistic or stylometric work you may want to keep stop words in, since their frequency is itself a signal. Toggle the option in this tool and watch the rankings update instantly to compare both views.

What is the difference between unigrams, bigrams, and trigrams in practice?

All three are word n-grams; the number just sets the sequence length. Unigrams are single words, so their frequency table is essentially a word-count list that shows which terms dominate a text. Bigrams are two-word pairs like "machine learning" and start to reveal phrases and collocations rather than isolated words. Trigrams are three-word runs such as "natural language processing" and capture even more specific recurring expressions, though counts drop as length grows because longer exact matches are rarer. In short, smaller n-grams show vocabulary, larger ones show phrasing. This tool also supports quadgrams and 5-grams for spotting repeated long phrases or boilerplate. Switch between sizes one to five using the tabs and compare how the rankings shift to pick the level that best fits your analysis.

Why do my n-gram counts change when I turn on cross-sentence n-grams?

By default this tool does not let an n-gram span a sentence boundary, so the last word of one sentence is never paired with the first word of the next. This prevents unrelated words from being glued into phrases that never really occur together, which keeps bigram and trigram counts accurate for phrase analysis. When you enable the allow cross-sentence n-grams option, sequences are counted straight across the whole text regardless of periods, so you get more total n-grams and some new pairs that bridge sentence breaks. Use the default for clean phrase and collocation work, and enable cross-sentence counting when you want raw sequence statistics over the entire document, such as for certain language-modeling experiments. Toggle it here and the totals and rankings recalculate immediately so you can see the effect.

How do I export n-gram frequency data to a spreadsheet or script?

After analyzing your text, use the download buttons to save the full results as either CSV or JSON. The CSV file opens directly in Excel, Google Sheets, or Numbers with columns for the n-gram, its count, and its percentage share, ready for sorting, charting, or pivot tables. The JSON file is structured for code and includes the n-grams alongside summary figures like total, unique, and the diversity ratio, which makes it easy to load into Python, R, or a Node script for deeper analysis. Although the on-screen table caps at 500 rows for performance, the exported files always contain the complete list of every n-gram found, so nothing is lost. You can also copy results to the clipboard for a quick paste. Run your text through this tool and download the format that fits your workflow.

How accurate is the N-Gram Extractor for SEO keyword density analysis?

It is accurate as a literal frequency counter: it reports exactly how many times each word and phrase appears and what share of the total each represents, which is the honest basis of keyword density. The percentage column tells you whether a target phrase shows up often enough to signal relevance or so often that it reads as keyword stuffing. For trustworthy SEO results, enable remove punctuation and fold case together so variants like "Apple" and "apple." are counted as one token, and consider removing stop words to surface real topic phrases. Remember that frequency alone is not a ranking factor; modern search engines weigh context and intent, so treat these counts as a diagnostic, not a quota. Paste your draft or competitor page here, check the bigram and trigram tables, and adjust your wording with confidence.

About the N-Gram Extractor

The N-Gram Extractor breaks any block of text into its repeating sequences and counts how often each one appears. Paste an article, a transcript, a set of product reviews, or a search-query export, and it returns ranked tables of word and character n-grams along with frequency counts, percentages, and a lexical-diversity score. It is built for SEO writers checking phrase repetition, linguists and students studying corpora, and developers prototyping anything that depends on frequency data.

An n-gram is a contiguous run of n items pulled from text. A unigram is a single word, a bigram is a pair such as "machine learning", and a trigram is a triple such as "natural language processing". The same idea applies to characters, where "th", "the", and "ther" are 2-, 3-, and 4-character n-grams. These sequences are the raw material behind autocomplete, language detection, spam filters, and the statistical language models that preceded today's neural systems.

What you can extract and adjust

The tool works at two levels at once, shown on separate tabs:

  • Word n-grams from size 1 to 5 — unigram, bigram, trigram, quadgram, and 5-gram.
  • Character n-grams from 1 to 5 characters, which are independent of word boundaries and useful for fuzzy matching and language fingerprinting.

Several options change how text is tokenized before counting:

  • Case sensitivity — keep "Apple" and "apple" separate, or fold them together (the default).
  • Remove stop words — drop common function words like "the", "of", and "and" so the meaningful phrases rise to the top.
  • Remove punctuation — strip symbols so "word." and "word" are treated as the same token.
  • Allow cross-sentence n-grams — by default sequences do not span a sentence boundary, which keeps unrelated phrases from being glued together; enable this to count across the whole text.
  • Minimum count filter — hide one-off sequences and show only n-grams that occur at least a set number of times.

What the results tell you

Each tab reports three headline numbers: total n-grams (every sequence found), unique n-grams (distinct sequences), and the diversity ratio. That ratio is the type-token ratio — unique divided by total, shown as a percentage. A high value signals varied wording; a low value flags repetition, which can mean a tight, focused text or a padded, formulaic one.

Below the stats, a bar chart highlights the top ten sequences, and a full table lists every n-gram by rank, count, and share of the total. The table displays up to 500 rows on screen for performance, but exports always contain the complete list. You can copy the results to the clipboard or download them as CSV or JSON for use in a spreadsheet, a script, or a larger analysis pipeline.

Real uses for frequency data

Frequency analysis answers practical questions quickly. An SEO editor can confirm whether a target phrase actually appears often enough — or far too often, which reads as keyword stuffing. A content team can scan customer reviews or support tickets for recurring bigrams that reveal common complaints or feature requests. Researchers use n-gram counts to compare writing styles, measure vocabulary richness, or build baseline distributions. Because the tool exports clean CSV and JSON, it doubles as a lightweight first step before deeper work in Python, R, or a notebook.

Private by design

Everything runs entirely in your browser. The text you paste is tokenized and counted on your own device using client-side JavaScript, with no upload to any server, no account, and no usage limit. You can analyze an unpublished draft, internal documents, or confidential transcripts without the content ever leaving your machine, and the page keeps working offline once it has loaded. Processing speed depends on your hardware rather than a server queue, so even long documents are handled in real time.