Home › Developer & IT › String Similarity Calculator
String Similarity Calculator
Compares two strings with the Levenshtein edit distance and similarity, Jaro and Jaro–Winkler similarity, the bigram Sørensen–Dice coefficient, the Hamming distance (equal lengths only) and the longest common subsequence length.
When to use
You need a fuzzy-match score for names, deduplication, spell-check suggestions or typo tolerance, or want to compare several similarity metrics on the same pair.
Do not use when: You need semantic similarity (embeddings), phonetic matching (Soundex/Metaphone) or strings longer than 2,000 characters.
Formula
Levenshtein: dynamic programming over insert/delete/substitute cost 1; Jaro = (m/|a| + m/|b| + (m − t)/m) / 3 with m matches within floor(max(|a|,|b|)/2) − 1 and t = transpositions/2; Jaro–Winkler = jaro + ℓ·0.1·(1 − jaro), ℓ = common prefix length ≤ 4; Dice = 2·|bigrams_a ∩ bigrams_b| / (|bigrams_a| + |bigrams_b|)
Strings are compared by Unicode code point (no normalisation; é as one code point and e + combining accent differ). The Winkler boost is applied for every Jaro value (no 0.7 threshold), matching the Wikipedia definition.
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
text_a | string | yes | First string to compare. | |
text_b | string | yes | Second string to compare. | |
case_sensitive | boolean | default false | When false (default) both strings are lower-cased before comparison. |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
levenshtein_distance | integer | Minimum number of single-character insertions, deletions or substitutions to turn text_a into text_b. | |
levenshtein_similarity | number | 1 − distance / max(length_a, length_b), from 0 to 1. | |
jaro | number | Jaro similarity based on matching characters within a window and transpositions. | |
jaro_winkler | number | Jaro boosted for a common prefix of up to 4 characters with scaling factor 0.1. | |
dice_coefficient | number | 2 × shared bigrams / (bigrams_a + bigrams_b), counting repeated bigrams. | |
hamming_distance | integer | Number of positions with different characters; only defined for strings of equal length (omitted otherwise). | |
longest_common_subsequence | integer | Length of the longest sequence of characters appearing in both strings in the same order (not necessarily contiguous). | |
length_a | integer | Code points in text_a. | |
length_b | integer | Code points in text_b. |
Example
kitten vs sitting: {"text_a":"kitten","text_b":"sitting"} → {"levenshtein_distance":3,"levenshtein_similarity":0.5714,"jaro":0.746,"jaro_winkler":0.746,"dice_coefficient":0.3636,"longest_common_subsequence":4}
MARTHA vs MARHTA (Winkler's example): {"text_a":"MARTHA","text_b":"MARHTA","case_sensitive":true} → {"jaro":0.9444,"jaro_winkler":0.9611,"levenshtein_distance":2,"hamming_distance":2,"longest_common_subsequence":5}
GET https://tttkmbb.com/api/v1/calculate/string-similarity?text_a=kitten&text_b=sitting
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/string-similarity(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/string-similarity · Markdown: https://tttkmbb.com/developer/string-similarity.md · JSON definition: https://tttkmbb.com/developer/string-similarity.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="string-similarity" - OpenAPI operationId:
calculate_string_similarity - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Levenshtein distance (Wikipedia) (reference)
- Jaro–Winkler distance (Wikipedia) (reference)
- Sørensen–Dice coefficient (Wikipedia) (reference)
FAQ
Which metric should I use?
Levenshtein for typos and edit-based matching, Jaro–Winkler for short names where the beginning matters, Dice for word-level similarity that tolerates reordering; a Jaro–Winkler above about 0.9 usually indicates the same name.
Why is Hamming distance missing?
It only exists for strings of equal length; for kitten (6) and sitting (7) it is undefined, so the output is omitted.
Are the metrics symmetric?
Yes, all reported metrics give the same value when text_a and text_b are swapped.
Related calculators
- Text Hash Calculator — Exact-match fingerprints instead of fuzzy scores.
- Percentage Calculator — Express a 0–1 similarity score as a percentage.