EditSafely

Generate All N-grams

Generate all ngrams of a string. Runs entirely in your browser, so your data never leaves your device.

0 chars · 0 lines

Output

The result appears here as you type.

Options
Tokens

How to use Generate All N-grams

  1. 1. Paste your text. Enter a sentence, phrase or block of text into the input pane. The tool tokenizes it into either words or characters before building grams.
  2. 2. Set N and the token type. Enter the gram size in N (gram size), then choose Words or Characters in Tokens. Word trigrams are common for language models; character n-grams suit fuzzy matching and spell-check indexes.
  3. 3. Read the generated grams. The output lists every consecutive sequence of N tokens, one per line, sliding one token at a time across the whole input from start to end.
  4. 4. Copy the list. Copy the n-grams from the output pane into a spreadsheet, a training dataset, or a search index build script.

When to use Generate All N-grams

Generate All N-grams breaks text into every overlapping sequence of a fixed size, at either the word or character level. It is the building block behind autocomplete indexes, fuzzy text search and simple language model features, and doing it by hand for anything longer than a sentence is tedious.

  • Building a search suggestion index. You're indexing product names for a typeahead search box and want character trigrams to support fuzzy matching. Feed each product name through and store the resulting grams alongside the record.
  • Feature engineering for a text classifier. A spam classifier uses word bigrams as features. Generate 2-grams from a batch of training sentences to see exactly which word pairs the model will see.
  • Checking phrase frequency in a transcript. You want to spot repeated three-word phrases in a meeting transcript. Word trigrams surface phrases like 'let's circle back' that show up more than once.
  • Preparing data for a Markov chain generator. A toy text generator needs overlapping word sequences from a source text to build its transition table. This tool produces exactly those sequences without writing a sliding-window loop.

Examples

Word trigrams

Input

the quick brown fox

Output

the quick brown
quick brown fox

About the Generate All N-grams tool

Generate All N-grams does its work locally, right in the browser. Generate all ngrams of a string. There is no upload step, no queue and no account, and your data never travels over the network.

It belongs to the String Tools collection on EditSafely, a set of 159 small, focused String utilities that share the same instant, private workspace.

You can shape the output with 2 settings, including N (gram size) and Tokens, and the result refreshes the moment you change one. A worked example further down the page shows exactly what the tool produces for a real input.

Running locally also makes the tool fast and dependable: results appear as you type or drop a file, there is no server outage that can take it down mid-task, and confidential data can be processed without a second thought.

Frequently asked questions

Does Generate All N-grams cost anything?

Yes, it is completely free. All 2,658 tools on EditSafely work without an account, a subscription or usage limits.

Is it safe to paste sensitive or confidential data?

No data leaves your device. The whole tool is JavaScript that runs inside your browser tab, so there is no upload, no server-side processing and no log of what you did. If you disconnect from the internet after the page loads, it keeps working.

How much text can I process at once?

There is no fixed limit. Because the work happens on your own device rather than on a shared server, the practical ceiling is your machine's memory, which comfortably handles inputs far larger than typical online tools allow.

Do I need to sign up or install anything?

Nothing to install and no account needed. Open the page in any up-to-date browser, including on a phone or tablet, and the tool is ready.

How do I use the result?

The output panel has a one-click copy button, and you can keep refining the input while you work; the result updates in place as you type.