Find the minimum number of single-character edits needed to turn one string into another.
Levenshtein distance counts the fewest single-character edits — inserting a character, deleting one, or substituting one for another — needed to turn one string into another. A distance of 0 means the strings are identical; the higher the number, the more they differ. It's the algorithm behind spell-checkers' "did you mean…" suggestions, fuzzy search, DNA sequence comparison, and the diff tools developers use to compare files line by line.
Levenshtein distance (also called edit distance) is the minimum number of single-character insertions, deletions, or substitutions needed to turn one string into another. Two identical strings have a distance of 0; completely different strings of length n and m have a distance of at most max(n, m).
It's the algorithm behind spell-checkers' "did you mean…" suggestions, fuzzy search, DNA sequence comparison, and the diff tools developers use to compare text.
d(i, j) = 0 if i = 0 or j = 0 d(i, j) = d(i-1, j-1) if a[i] = b[j] d(i, j) = 1 + min(d(i-1,j), d(i,j-1), d(i-1,j-1)) otherwise
The calculator builds a dynamic-programming table where each cell d(i, j) holds the edit distance between the first i characters of string A and the first j characters of string B. It fills the table row by row: if the current characters match, the cost carries over unchanged from the diagonal; otherwise it takes the cheapest of a deletion, insertion, or substitution and adds 1.
The final answer is the bottom-right cell of the table — the distance between the full strings.
Comparing "kitten" and "sitting":
Via dynamic programming: a table is built where each cell is the cheapest combination of a matching character, a substitution, an insertion, or a deletion, built up from the start of both strings to the end.
It depends on string length — a distance of 2 is huge for two 3-letter words but tiny for two 50-character sentences. This tool also shows a length-adjusted similarity percentage for that reason.
Yes, as implemented here — "Cat" and "cat" have a distance of 1 (one substitution) because capital and lowercase letters are different characters.
Levenshtein counts edit operations (good for typos, spell-checking). Jaro similarity scores based on matching characters and transpositions within a limited window, and tends to work better for short strings like names.
This tool caps input at 200 characters per string, since the algorithm's table size grows with the product of both lengths — well beyond what's needed for words, names, or short phrases.