HomeDeveloper & 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

ParameterTypeUnitRequiredDescription
text_astringyesFirst string to compare.
text_bstringyesSecond string to compare.
case_sensitivebooleandefault falseWhen false (default) both strings are lower-cased before comparison.

Outputs

OutputTypeUnitDescription
levenshtein_distanceintegerMinimum number of single-character insertions, deletions or substitutions to turn text_a into text_b.
levenshtein_similaritynumber1 − distance / max(length_a, length_b), from 0 to 1.
jaronumberJaro similarity based on matching characters within a window and transpositions.
jaro_winklernumberJaro boosted for a common prefix of up to 4 characters with scaling factor 0.1.
dice_coefficientnumber2 × shared bigrams / (bigrams_a + bigrams_b), counting repeated bigrams.
hamming_distanceintegerNumber of positions with different characters; only defined for strings of equal length (omitted otherwise).
longest_common_subsequenceintegerLength of the longest sequence of characters appearing in both strings in the same order (not necessarily contiguous).
length_aintegerCode points in text_a.
length_bintegerCode 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

Sources

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