Calcoid

Levenshtein Distance Calculator

Compute the edit distance between two strings with Levenshtein, Damerau-Levenshtein (adds transpositions), or Hamming. Returns distance, similarity percent, and per-operation backtrace counts. Handles strings up to 5,000 characters.

Strings to compare

6 / 5,000
7 / 5,000

Options

Result

Levenshtein distance

3

Need 3 edits to transform "kitten" to "sitting".

Similarity57.14%
Max possible distance7
Length A6
Length B7
Exact matchNo
Similar (>= 80%)No

Edit operations (backtrace)

Insertions
1
Deletions
0
Substitutions
2
Transpositions
0

Counts come from walking the dynamic-programming matrix back to (0, 0). Ties prefer substitution over insertion over deletion, but the total always equals the distance.

Edit Distance Examples

Source and targetMethodDistance
kitten to sittingLevenshtein3
abcd to acbdLevenshtein2
abcd to acbdDamerau-Levenshtein1
karolin to kathrinHamming3
flaw to lawnLevenshtein2
abcd to abdcDamerau-Levenshtein1

Frequently Asked Questions about the Levenshtein Distance Calculator

What is Levenshtein distance and where does the name come from?
Levenshtein distance is the minimum number of single-character insertions, deletions, or substitutions needed to turn one string into another. It was published in 1965 by Soviet mathematician Vladimir Levenshtein in a paper on binary codes capable of correcting deletions, insertions, and reversals. The name stuck even though the same metric had been discovered a few times before; today it underpins spell checkers, fuzzy search, diff tools, and DNA alignment scoring.
How is Damerau-Levenshtein different from regular Levenshtein?
Damerau-Levenshtein adds transposition of adjacent characters as a one-step edit. This calculator implements optimal string alignment, a restricted variant in which a substring cannot be edited more than once. Full Damerau-Levenshtein can produce a different result for some overlapping edits.
What is Hamming distance and why does it require equal-length strings?
Hamming distance counts the positions where two equal-length strings differ, nothing more. Richard Hamming defined it in 1950 for error-detecting and error-correcting codes, where every codeword has a fixed bit length, so 'equal length' is built into the problem. The calculator returns an error rather than padding shorter input because padding would silently change the answer; if you need to compare strings of different length, switch to Levenshtein or Damerau-Levenshtein.
When would I actually use edit distance?
Edit distance can help rank spelling candidates, compare OCR output, or find similar identifiers. It is only one signal: names, natural language, source code, and biological sequences often need domain-specific costs or algorithms. Do not treat a low distance as proof that two records identify the same person or item.
How fast is this for long strings?
This implementation uses O(m x n) dynamic programming, so work grows with the product of the input lengths. The calculator rejects comparisons above one million cells before allocating the table. For larger workloads, use a thresholded, banded, or linear-memory algorithm.

Related Calculators

More calculators in "Tech"

See all 98 calculators in "Tech"