This calculator computes the Levenshtein distance between two strings. The distance is the minimum number of single-character edits needed to turn one string into the other, where the allowed edits are:
Enter two strings above and click Compute. The tool will return an integer distance. A result of 0 means the strings are identical; larger numbers mean more edits are required and therefore lower similarity.
Formally, the Levenshtein distance between two strings A and B is defined as the minimum number of insertions, deletions, and substitutions needed to transform A into B. The standard algorithm uses dynamic programming and fills a matrix where each entry represents the distance between prefixes of the two strings.
Let i be the length of the prefix of A and j the length of the prefix of B. The value d(i, j) is the Levenshtein distance between the first i characters of A and the first j characters of B. The recurrence is:
Here, cost = 0 if the i-th character of A equals the j-th character of B, and cost = 1 otherwise. The first row and first column of the matrix are initialized to represent distances involving an empty string:
The final answer is d(|A|, |B|), where |·| denotes string length.
A classic example uses the words kitten and sitting. One optimal sequence of edits is:
k with s: kitten → sittene with i: sitten → sitting at the end: sittin → sitting
That sequence uses three single-character edits, so the Levenshtein distance between kitten and sitting is 3. The dynamic programming matrix guarantees that this is the minimum possible number of edits, even when there are many alternative paths.
The calculator returns a non-negative integer. You can interpret it as follows:
Keep in mind that the raw distance depends on the string lengths. A distance of 3 is small for 20-character strings but large for 4-character strings. For some applications, you may want to convert the distance to a normalized similarity score, such as 1 − (distance / max_length), but this calculator reports the raw distance only.
Because it is simple and well-defined, Levenshtein distance appears in many practical scenarios:
recieve to receive.Jon Smith vs John Smyth).In each of these settings, a lower distance suggests higher similarity, and threshold rules like "accept if distance ≤ 2" are common.
Levenshtein distance is only one way to compare strings. Other metrics behave differently and are useful in different contexts. The table below contrasts a few common approaches.
| Metric | Key idea | When it is a good fit |
|---|---|---|
| Levenshtein distance | Counts insertions, deletions, and substitutions; all edits cost 1 in this calculator. | General-purpose fuzzy matching where typos, missing characters, and substitutions all matter. |
| Hamming distance | Counts substitutions only; strings must be the same length. | Error-detecting codes, bit strings, or fixed-length IDs where insertions/deletions are impossible. |
| Damerau–Levenshtein | Like Levenshtein but also treats adjacent transpositions (e.g., ab ↔ ba) as a single edit. |
Correcting common keyboard typos where characters are swapped. |
| Jaro / Jaro–Winkler | Weighted comparison based on matching characters and their relative order. | Short strings such as names, where prefix similarity is particularly important. |
If your task needs one of these variants, this page can still provide a baseline by showing how far apart two strings are under the classic Levenshtein definition.
To keep the tool predictable and fast for everyday use, the implementation makes several assumptions:
1. There is no weighting by character type, keyboard layout, or position in the string.
ab → ba) counts as two edits (delete + insert or two substitutions), not one. This differs from Damerau–Levenshtein distance.
These constraints are typical for a reference implementation of Levenshtein distance and are suitable for most text-oriented tasks such as spell checking, fuzzy search, and simple record matching.