TTKTheTextKit

String Distance Calculator

Enter two texts and see how far apart they are: the Levenshtein edit distance and a similarity percentage, the Damerau distance that counts a swap as one edit, the Hamming distance for texts of equal length, and the Jaro and Jaro-Winkler scores. A step by step list shows one shortest set of edits. Everything runs in your browser.

Levenshtein distance
3
Similarity 57.14%
Damerau (swaps count 1)
3
Optimal string alignment
Hamming distance
n/a
Needs two texts of the same length
Jaro similarity
0.7460
Jaro-Winkler similarity
0.7460
Extra weight for a shared start
Lengths
6 and 7
Counted in characters, not bytes
One shortest set of edits
ksittein+g

Grey is kept. Amber is a substitution (old letter struck through, new one below). Green is an insertion. Red is a deletion.

The Levenshtein distance is the fewest single-character edits (insert, delete or replace) that turn one text into the other: kitten to sitting is 3. Divided by the length of the longer text it gives a similarity from 0 to 100 percent. The Damerau version also counts swapping two neighbouring letters as one edit, which suits typos such as teh for the. The Hamming distance counts the positions that differ and only exists for texts of equal length. Jaro and Jaro-Winkler give a score from 0 to 1 that favours texts sharing letters in nearly the same order, and is often used to match names. Characters are compared by code point, so an emoji counts as one. Up to 2,000 characters per text. Everything is worked out in your browser and nothing is uploaded.

Related Tools

[5 suggestions]

About the String Distance Calculator

The Levenshtein distance is the smallest number of single-character edits, each an insertion, a deletion or a substitution, needed to turn one text into another. Turning kitten into sitting takes 3 edits: replace k with s, replace e with i, and add g. Dividing the distance by the length of the longer text and subtracting from 1 gives a similarity, here 1 - 3/7, about 57 percent. The Damerau distance, in its optimal string alignment form, also counts the swap of two neighbouring characters as one edit, so teh to the is 1 where Levenshtein gives 2. The Hamming distance counts the positions at which two texts of equal length differ, such as 3 for karolin and kathrin, and does not exist for texts of different lengths. The Jaro similarity runs from 0 to 1 and is built from the matching characters and how many are out of order. MARTHA and MARHTA score 0.9444. Jaro-Winkler adds a bonus for a shared start of up to four characters and gives 0.9611 for the same pair, which is why it is popular for matching names. The texts are compared by code point, so an emoji counts as one character, with options to ignore case and spaces. Each text can be up to 2,000 characters. Nothing is uploaded.

What is the Levenshtein distance?▾

The fewest single-character insertions, deletions and substitutions that turn one text into another. For kitten and sitting it is 3. A distance of 0 means the texts are identical.

What is the difference between Levenshtein and Damerau distance?▾

The Damerau version also counts swapping two adjacent characters as one edit. For teh and the, the Damerau distance is 1 and the Levenshtein distance is 2, which suits typing mistakes.

When can I use the Hamming distance?▾

Only for two texts of the same length. It counts the positions where the characters differ and ignores insertions and deletions. For karolin and kathrin it is 3.

What is Jaro-Winkler similarity used for?▾

Matching short strings such as names. It scores from 0 to 1 and gives extra credit when the texts begin the same way. MARTHA and MARHTA score 0.9611, and a score near 1 means a close match.

Is my data uploaded?▾

No. The calculation runs in your browser and the text you enter is not sent anywhere.