ForHosting KIT · Text & AI

Sørensen–Dice string similarity calculator

Score how alike two texts are by the character pairs they share: night and nacht have only ht in common and score 0.25, while identical strings score 1. Useful for near-duplicate names and typos. 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 a
night
Text b
nacht
You get
Coefficient
0.25
Percent
25
Bigrams a
4
Bigrams b
4

The Sørensen–Dice coefficient is a classic fuzzy string similarity measure built from shared character bigrams rather than exact equality or full edit paths. Given two texts, this calculator extracts every consecutive pair of characters in each string, treats those pairs as multisets, and returns twice the size of their intersection divided by the sum of the two multiset sizes. The score sits between zero and one: identical strings yield one, completely disjoint bigram bags yield zero, and everyday near-matches such as night versus nite or reordered short tokens land in between. Because the method depends on overlapping pairs instead of global alignment, it tolerates minor spelling differences and is less brittle to word order than pure Levenshtein distance when comparing bag-like labels. Students, data engineers, and product teams use it for deduplication hints, search ranking features, and homework checks without standing up a machine-learning stack.

How the Sørensen–Dice bigram coefficient is defined

Start with two strings A and B. Form the multiset of character bigrams for each string: for a string of length n you obtain n minus one overlapping pairs, so night yields ni, ig, gh, ht. Count how many times each pair appears so repeated letters contribute multiple tokens rather than a single set membership.

The intersection size is the sum over every distinct bigram of the minimum of its counts in A and in B. The Sørensen–Dice coefficient is then two times that intersection divided by the total number of bigrams in A plus the total in B. When both normalized strings are empty or otherwise identical, the coefficient is defined as one.

When the strings differ and at least one has fewer than two characters, there are no comparable bigrams and the coefficient is zero. The formula is fully deterministic and independent of locale collation beyond ordinary Unicode string indexing, which keeps results stable for automated tests and multi-region deployments. This is not semantic similarity: apple and fruit share no character pairs and score near zero even though a human might call them related.

Use embedding-based tools when meaning matters; use Dice when surface form and spelling proximity matter.

Where fuzzy bigram similarity earns its keep in products

Catalog and CRM teams apply a Sørensen–Dice string similarity calculator when merging near-duplicate company names, product titles, or address lines that differ by a few characters without matching full-text fuzzy search configuration. Search and ranking engineers use the coefficient as a cheap lexical feature next to BM25 or token overlap, especially for short queries and titles where character pairs capture typos better than whole-word equality.

Localization and content QA scripts flag candidate strings that look almost identical after translation memory edits so reviewers focus on true meaning drift rather than accidental spelling variants. Classroom and interview prep platforms need a deterministic oracle for the textbook formula so students can check homework on night versus nacht style pairs and see intersection and bigram counts, not only a black-box score.

Prefer this tool when you want an explainable multiset formula; switch to edit distance when insertion and deletion costs dominate, or to embeddings when semantic relatedness is the product goal. Keep inputs short when possible, pin coefficient and intersection in tests, and you get reproducible fuzzy scores without a vector database or GPU.

Near-duplicate name and title matching

Score product titles, vendor names, or SKU labels that differ by typos or minor spelling so merge rules can soft-match without full manual review.

Lexical feature for search ranking

Add a bigram Dice coefficient between query and title as a transparent feature alongside token overlap in lightweight rankers and offline evaluations.

Homework and algorithm teaching

Let students verify the multiset bigram formula for textbook pairs and inspect intersection and bigram counts next to the coefficient.

What is the Sørensen–Dice coefficient for two strings?

It is two times the multiset intersection of character bigrams divided by the sum of bigram counts in both strings, yielding a score from 0 to 1. Identical strings score 1.

What if one string is empty or only one character long?

If the normalized strings are identical they score 1. If they differ and either side has fewer than two characters, no bigrams can match and the coefficient is 0.

Why do night and nacht score 0.25?

Each word has four character pairs, and the only one they share is ht. Twice that one shared pair, divided by the eight pairs in total, gives 0.25, which is 25 percent.

Do uppercase and lowercase letters change the score?

Not by default: both texts are lowercased first, so Night and night count as identical. Switch on case-sensitive comparison when case matters, for example with codes, passwords or language identifiers.

Does a high score mean two words mean the same thing?

No. The coefficient only measures shared spelling. Apple and fruit share no character pairs and score near zero even though they are related, so use it for typos and near-duplicates, not for meaning.

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/dev/dice-coefficient

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/dev/dice-coefficient \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text_a":"night","text_b":"nacht"}'
{
  "text_a": "night",
  "text_b": "nacht"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev.dice_coefficient",
  "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.

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.

How the Sørensen–Dice bigram coefficient is defined

Case folding is optional: by default both sides are lowercased before bigrams are taken so Night and night score as perfect matches; set case_sensitive true if you need case-aware comparison for passwords, codes, or language identifiers.

Input contract, response fields, and validation errors

Example: night and nacht share the bigram ht once out of four pairs each, so intersection is one, denominator is eight, and the coefficient is zero point two five. Failed validation is not billed. POST a JSON body with two required string fields text_a and text_b. Aliases a, string1, s1, left, first map to text_a, and b, string2, s2, right, second map to text_b, so short client payloads remain readable. Optional case_sensitive defaults to false; accept boolean true or false, or common string forms such as true, false, one, and zero. Each string may be empty only as a deliberate edge case; missing fields, non-string types, and strings longer than ten thousand characters fail with invalid_input naming the field. On success the response echoes text_a, text_b, and the resolved case_sensitive flag; coefficient is the unit interval score rounded to twelve decimal places for stable goldens; percent is coefficient times one hundred for dashboards that prefer a percentage; bigrams_a and bigrams_b report how many pairs each side contributed; intersection is the multiset overlap count; and formula restates DSC equals two times intersection over the sum of multiset sizes. Pair the score with your own threshold policy for soft matches; this endpoint never invents a pass or fail label beyond the numeric measure. Successful parse calls use the published $0.002 base price with no model tokens and no outbound network.

How do I call the Sørensen–Dice string similarity calculator?

Send text_a and text_b as strings. Optionally set case_sensitive true to preserve case. The API returns coefficient, percent, bigrams_a, bigrams_b, intersection, and formula.

Does case matter?

By default case_sensitive is false and both strings are lowercased before bigrams are extracted. Set case_sensitive to true for case-aware comparison.

What does the calculator 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 →