ForHosting KIT · Text & AI

Character bigram frequency counter

Paste banana and get its five letter pairs ranked: an and na appear twice each, ba once. Each pair shows its count and share of the total, a classic fingerprint for language detection, cipher work and keyboard studies. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Text
banana
You get
Length
6
Total bigrams
5
Unique bigrams
3

Character bigrams are every pair of letters that sit next to each other in a string—ba, an, na, an, na inside banana—and their frequencies are a classic fingerprint of language, cipher, and keyboard layout. Linguists and NLP students use bigram tables for language-detection baselines; cryptanalysis courses plot digraphs to spot English-like structure in ciphertext; type designers and input-method researchers watch which pairs dominate so spacing and key placement can be tuned. This character bigram frequency counter accepts a text string, optionally folds case, slides a two-character window across the whole string, and returns a ranked table of each unique pair with raw count and share of all adjacent pairs.

What character bigrams are and why their frequencies matter

A character bigram is simply two consecutive characters read left to right: in the word banana the successive pairs are ba, an, na, an, and na. Counting how often each pair appears produces a multiset frequency table that is far richer than single-letter histograms for many downstream tasks. Natural languages show strong pair preferences—th and he dominate English running text, while other pairs are rare—so a short sample’s bigram profile often separates languages better than raw letter counts alone.

Classic cryptanalysis textbooks teach digraph frequency as a step after monogram analysis: even when letters are substituted, common English pairs reappear as repeating ciphertext digraphs and guide crib attacks. Typography and keyboard layout work use the same statistics for a different reason: high-frequency pairs inform kerning candidates, digraph ligatures, and key travel cost models for alternative layouts. Spaces, punctuation, and digits are characters like any other, so Hello world yields a space-containing bigram between o and w.

Because the window is character-based on JavaScript UTF-16 code units, astral-plane emoji may appear as surrogate halves—suitable for byte-like diagnostics but not for grapheme-cluster linguistics. Keep inputs under the published character ceiling and pin ranked rows in tests so automation stays reproducible across runtimes.

Language-detection experiments

Build baseline digraph profiles from sample paragraphs and compare bigram share vectors across candidate languages without a full NLP library.

Cryptanalysis and classroom CTFs

Tally ciphertext digraphs to spot high-frequency pairs that may map to common English letter combinations during substitution attacks.

Typography and keyboard tuning

Rank adjacent character pairs in corpus snippets to prioritize kerning candidates or score alternative keyboard layouts by pair travel cost.

Are spaces and punctuation counted?

Yes. Every adjacent pair of characters is counted, including spaces, digits, and punctuation. There is no tokenizer that strips non-letters.

What if my text is empty or only one character?

Bigrams need two consecutive characters; empty or single-character input cannot form an adjacent pair and is not billed.

How many pairs does a text produce?

Always one fewer than its number of characters, because the pairs overlap. The six letters of banana give five pairs, ba, an, na, an and na, and only three of them are different.

Are uppercase and lowercase pairs counted separately?

By default, yes: Ab and ab are two different pairs. Turn off case sensitivity and the whole text is lowercased before counting, so Hello and hello add to the same pairs.

What are character bigram frequencies used for?

To compare languages, since pairs like th and he dominate English text; to spot the most repeated pairs in a substitution cipher; and to choose kerning pairs or score keyboard layouts by how often keys follow each other.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/str/char-bigram-frequency

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/str/char-bigram-frequency \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"banana"}'
{
  "text": "banana"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "str.char_bigram_frequency",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_chars100000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Empty text and strings shorter than two characters fail with invalid_input instead of a hollow empty table.

What character bigrams are and why their frequencies matter

This endpoint implements only the deterministic count: for a string of length n it records n minus one overlapping windows, tallies identical two-character keys, sorts by descending count with a stable lexicographic tie-break on the bigram string, and attaches each row’s share of the total window count. It does not guess language labels, crack ciphers, or recommend fonts; those products consume the table you get back. Case is preserved by default so Ab and ab stay distinct; set case_sensitive to false when you want a case-folded profile for language experiments.

Input contract, response shape, and error behaviour

Example: banana yields five total bigrams with an and na each counting two, ba counting one, ranks ordered by frequency then bigram string. POST a JSON body with one required field, text, the non-empty string you want scanned for adjacent pairs. Aliases input, string, value, content, and s are accepted so scripts can reuse common field names. Optional case_sensitive defaults to true and may also be sent as caseSensitive or sensitive; when false the entire string is lowercased before counting so Hello and hello share the same digraph keys. Optional top (aliases limit, n) is an integer from one to ten thousand that truncates the ranked table after sorting; omit it to receive every unique bigram. Missing text, empty strings, non-string objects and arrays, and values that remain shorter than two characters after case folding fail with invalid_input and a message that names the problem—those validation failures are not billed. Over-length text above the declared max_chars limit is also rejected. On success the body echoes the original text and its length, reports total_bigrams as length minus one for the scanned form, unique_bigrams as the number of distinct pairs, case_sensitive as resolved, optional top when you set it, a frequencies array of objects each with rank, bigram, count, and share rounded to six decimal places, and method set to char_bigram_frequency. Pair the table with your own language models or charts if you need classifiers or heatmaps; this endpoint counts only and does not emit plots or model predictions.

Where a character bigram frequency API earns its keep

Language-detection prototypes and teaching labs need a deterministic digraph oracle so every student notebook and grader agree on the same ranks for the same sample paragraph. Typography and keyboard-layout experiments pull pair statistics from corpus snippets to prioritize kerning pairs or score layout cost without shipping a full NLP stack. Failed validation does not consume balance. Cryptanalysis coursework and CTF write-ups use adjacent-pair tallies as a first filter before heavier tools, and a tiny parse API avoids reimplementing sort and share arithmetic in every language.

How do I count character bigram frequencies in a string?

Send a JSON body with text set to your string (at least two characters). The API slides a two-character window across the text and returns each unique pair ranked by count with a share of all adjacent pairs.

What does case_sensitive do?

Default true keeps letter case so Ab and ab are different bigrams. Set case_sensitive to false to lowercase the text before counting, which is common for language-detection baselines.

What does the character bigram frequency counter cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →