What is edit distance, and what does this tool measure?
Edit distance answers a simple question: how many small changes does it take to turn one text into another? The best known measure is the Levenshtein distance, named after the Russian mathematician Vladimir Levenshtein. It counts the fewest single-character insertions, deletions and substitutions needed. Turning "kitten" into "sitting" takes three: replace k with s, replace e with i, add g. A distance of zero means the texts are identical, and the larger the number, the further apart they are.
People use it for fuzzy matching and cleaning data: finding duplicate customer names, suggesting "did you mean" corrections, matching product names that were typed by hand, grading spelling exercises, comparing a transcription with its source, or checking how much a document changed between versions. For a ready-made side-by-side view of changes in whole documents, a text diff is usually better. This tool is about the number and the similarity score.
Seven metrics are available. Levenshtein, Damerau-Levenshtein (the optimal string alignment variant, where swapping two neighbouring characters costs one edit instead of two), the longest common subsequence (LCS), and the Hamming distance (positions that differ, defined only when both texts have the same length) are distances. Jaro, Jaro-Winkler and Sørensen-Dice (on pairs of characters) are scores between 0 and 1. For the distance metrics, the similarity percentage is one minus the distance divided by the length of the longer text. Everything is computed in your browser and nothing is sent anywhere.
How to compare two texts
- Type or paste the two texts into "Text A" and "Text B". The page starts with the classic pair "kitten" and "sitting".
- Pick a metric. Each one comes with a one-line explanation under the selector. Levenshtein is the right default. Choose Jaro-Winkler for short names and Damerau when typos often swap neighbouring letters.
- Choose the unit: characters (counted by Unicode code point, so an emoji counts as one) or words. Word mode is useful for sentences, where you care about replaced words more than letters.
- Set the normalisation. "Ignore case", "Ignore accents" and "Trim and collapse spaces" are applied to both texts before comparing. Your choices are remembered on this device, but the texts themselves are not stored.
- Read the result: the distance or score, the similarity percentage and the number of units in common. Below, a list shows exactly what changes from A to B: struck out in red for what leaves A, underlined in green for what enters B. The swap button exchanges the two texts.
Examples
The textbook case: kitten and sitting
With Levenshtein by characters, the distance is 3 and the similarity 57%. The edit list reads: replace k with s, keep i, t and t, replace e with i, keep n, add g. The longest common subsequence has length 4, Jaro gives 0.746 and Sørensen-Dice gives 0.364. Hamming shows a note instead of a number, because the texts have 6 and 7 characters.
A transposed pair: martha and marhta
Two letters trade places. Levenshtein sees two substitutions and returns 2 (67% similar). Damerau counts the swap as a single edit and returns 1 (83%). Jaro-Winkler gives 0.961, because the texts share a long beginning, and Hamming gives 2.
Saturday and Sunday
Levenshtein 3 (62.5% similar)
LCS 5
Jaro 0.719
Jaro-Winkler 0.7475
Dice 0.333Accents and case
"café" versus "cafe" has a distance of 1 by default. Turn on "Ignore accents" and the distance drops to 0 and the similarity to 100%. With "Ignore case" on as well, "Café" and "cafe" also match. If you only want to compare the letters, see also the accent remover.
Word by word
Comparing "the quick brown fox" with "the slow brown dog jumps" by words gives a distance of 3: two words replaced and one added. The similarity is 40%, because the longer text has five words.
Common mistakes
- Using Hamming on texts of different length. It is undefined, so the tool says so and shows no number. Choose another metric or equalise the lengths.
- Reading a score as a distance. For Jaro, Jaro-Winkler and Dice, 1 means identical and 0 means nothing in common. For Levenshtein, Damerau and Hamming, 0 means identical.
- Forgetting that case and accents count. "Maria" and "maria" differ by one edit unless you switch case folding on.
- Expecting the same result between Levenshtein and Damerau. They only differ when two adjacent characters are exchanged.
- Judging long texts by the percentage alone. One changed character in a ten-letter name is a 90% match, which is a big difference. In a long article it would be nearly 100%. Pick a threshold that fits the length you are comparing.
- Expecting meaning. These metrics compare spelling. "Big" and "large" are far apart even though they mean the same thing.
Frequently asked questions
What is a good similarity threshold for matching names?
There is no universal value. For short names, many people start with Jaro-Winkler above 0.9 or Levenshtein similarity above 80%, then review the borderline cases by hand. Try your own real pairs in the tool before fixing a number.
Does it handle accents, emoji and non-Latin scripts?
Yes. Texts are split by Unicode code point, not by UTF-16 unit, so "ñ" typed as one character and an emoji each count as one unit. A letter written as a base letter plus a combining accent counts as two units unless you ignore accents, which normalises it first.
How long can the texts be?
The distance is always exact. For very long texts the list of edits is hidden to keep the page responsive, and the tool says so. If you need to compare whole files, use text diff.
Is it the same as the diff algorithm?
Related but not identical. A diff tries to show a readable set of changes between lines or words. The Levenshtein edit list is one cheapest script among possibly several equally cheap ones.
Can I compare two lists of items instead of two texts?
Use the list comparison tool to see which items are in one list and not the other.