Levenshtein Distance Calculator

Find the minimum number of single-character edits needed to turn one string into another.

Type something into both boxes above to compare them.

What is Levenshtein Distance?

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.

What is the Levenshtein Distance Calculator?

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.

How to use it

  1. Type or paste the first string into "String A."
  2. Type or paste the second string into "String B."
  3. The edit distance and a length-adjusted similarity percentage update instantly.
  4. Use "Load example" to see a working pair ("kitten" → "sitting") if you want to try it first.

Formula / how it works

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.

Example

Comparing "kitten" and "sitting":

k→s (substitute), e→i (substitute), insert g at the end
Levenshtein distance = 3

Frequently asked questions

How is Levenshtein distance calculated?

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.

What's a good distance to consider strings "similar"?

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.

Is Levenshtein distance case-sensitive?

Yes, as implemented here — "Cat" and "cat" have a distance of 1 (one substitution) because capital and lowercase letters are different characters.

How is this different from Jaro similarity?

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.

Is there a maximum string length?

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.