Levenshtein Distance Calculator
Calculate the edit distance between two strings and see the operations needed to transform one into the other.
How to Use the Levenshtein Distance Calculator
- Enter the first string in the First string field.
- Enter the second string in the Second string field.
- Click Calculate — the edit distance, similarity percentage, and operation list are displayed instantly.
- Expand the Distance matrix to see the full dynamic programming table used for the computation.
Schnellreferenz
| Von | Nach |
|---|---|
| kitten → sitting | Distance: 3 |
| Saturday → Sunday | Distance: 3 |
| hello → hello | Distance: 0 (identical) |
| abc → xyz | Distance: 3 (all replaced) |
| cat → cart | Distance: 1 (insert r) |
| book → back | Distance: 2 |
Anwendungsfälle
- •Building spell-check suggestions by finding dictionary words closest to a misspelled input.
- •Comparing DNA or protein sequences in bioinformatics research.
- •Implementing fuzzy search in databases and search engines.
- •Measuring similarity between user-submitted text and reference answers in educational apps.
Formel
The Levenshtein distance between two strings is the minimum number of single-character edits — insertions, deletions, or substitutions — required to transform one string into the other. It is computed using dynamic programming: a matrix of size (|s1|+1) × (|s2|+1) is filled where each cell represents the edit distance between prefixes of the two strings.
Häufig gestellte Fragen
What is Levenshtein distance?
Levenshtein distance (also called edit distance) is a metric for measuring how different two strings are. It counts the minimum number of single-character insertions, deletions, or substitutions needed to change one string into the other. A distance of 0 means the strings are identical; a higher distance means they are more different.
How is similarity percentage calculated from edit distance?
Similarity is derived from the Levenshtein distance using the formula: similarity = (1 − distance / max(len1, len2)) × 100%. For example, if two strings of length 7 and 8 have an edit distance of 3, the similarity is (1 − 3/8) × 100% = 62.5%.
What are common applications of Levenshtein distance?
Levenshtein distance is widely used in spell checkers to suggest corrections, in DNA sequence alignment for bioinformatics, in fuzzy string matching for search engines, in plagiarism detection tools, and in natural language processing for tasks such as named entity recognition and machine translation evaluation.