Edit Distance Calculator
Levenshtein distance is the number behind spell-checkers, fuzzy search and DNA alignment: the fewest insertions, deletions and substitutions that turn one string into another. Most calculators give you the number. This gives you the actual edits, then replays them over the first word and checks the result really is the second — so the number is demonstrated rather than asserted.
What this generator does
Builds the standard Levenshtein table, then walks it backwards to recover the optimal alignments — how many there are in total, and the first few in full. Every non-matching step is an edit, and every alignment shown must replay to reproduce the second string exactly.
How to use this tool
- Enter the word you are starting from.
- Enter the word you want to reach.
- Run, and read the numbered list of edits.
- Check the count: it matches the number of listed steps exactly.
Understanding the controls
- First word
- The starting string. Any characters work — this is not limited to dictionary words.
- Second word
- The target string. Swapping the two gives the same distance, since the measure is symmetric.
Common use cases
- Explaining why a spell-checker suggested a particular correction
- Measuring how close two strings are for a fuzzy match threshold
- Teaching Levenshtein distance with the alignment made visible
- Checking a distance implementation against a worked example
- Comparing product codes or names that differ slightly
How this generator works
Each cell of the table holds the distance between two prefixes, built from the three cells above and to its left: a substitution, a deletion or an insertion, whichever is cheapest, with a match costing nothing. The bottom-right cell is the answer. Walking back from it recovers an alignment that achieves it — usually there are several, so a second pass over the same table counts them all (the routes into a cell are the sum of the routes into the cells a shortest path can come from), and a depth-first walk lists the first few in full. Ties are broken the same way every time, so the alignment shown first is reproducible. Before display the alignment is replayed over the first string and the number of non-matching steps is counted, and both must agree with the table.
Randomness and fairness
Nothing here is random. Two strings in, one distance out, identical every time.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- All three edit types cost one, so this is plain Levenshtein — weighted variants that treat a substitution as dearer than an insertion give different answers.
- Transpositions count as two edits, not one; the Damerau variant that counts them as one is a different measure.
- Comparison is character by character with no case folding or accent handling, so \u201cCafe\u201d and \u201ccaf\u00e9\u201d are two edits apart.
- At most eight alternative alignments are listed. The count beside them is exact up to a million, above which it is reported as a floor rather than a total.
Privacy and your data
Both strings stay in your browser. Nothing you type is transmitted, stored or included in analytics.
Related generators
- Text Diff GeneratorCompares two texts line by line and shows the smallest set of changes, checked by applying them back to the original.
- Huffman Code GeneratorBuilds an optimal prefix code for your text, shows every character's bit pattern, and decodes the bits back to prove it works.
- Text Wrapping and Raggedness GeneratorWraps text to a fixed width greedily, scores how ragged the right edge is, and checks every word survived in order.
- Anagram CheckerCheck whether two words or phrases are anagrams, and see the sorted letters that prove it either way.