Enter two strings and instantly calculate their edit distance — how many single-character insertions, deletions, or substitutions it takes to transform one into the other. Visualize the full DP matrix, trace the edit path, and run batch comparisons. Everything runs in your browser with no server, no sign-up, no tracking.

Edit Distance
Similarity
0 Insertions
0 Deletions
0 Substitutions
Similarity
Batch Compare

Enter one pair per line, separated by a comma: word1,word2


What Is Levenshtein Distance?

The Levenshtein distance (also called edit distance) between two strings is the minimum number of single-character edits — insertions, deletions, and substitutions — needed to transform one string into the other.

The classic example: transforming “kitten” into “sitting” requires 3 operations, so their Levenshtein distance is 3.

OperationExampleCost
Substitutionk → s (kitten → sitten)1
Substitutione → i (sitten → sittin)1
Insertionsittin → sitting1

Similarity % is computed as (1 − distance / max(len_a, len_b)) × 100.


How the DP Algorithm Works

The calculator builds an (m+1) × (n+1) matrix where m and n are the lengths of the two strings. Each cell dp[i][j] stores the minimum edit distance between the first i characters of string A and the first j characters of string B. The recurrence is:

  • If A[i] == B[j]: dp[i][j] = dp[i-1][j-1] (no cost)
  • Otherwise: dp[i][j] = 1 + min(dp[i-1][j-1], dp[i-1][j], dp[i][j-1]) (substitute, delete, insert)

Tracing back through the matrix from dp[m][n] reveals the specific sequence of operations shown in the step-by-step breakdown.


Common Use Cases

ApplicationHow edit distance helps
Spell checkingFind the closest dictionary word
DNA sequencingMeasure genetic sequence similarity
Fuzzy searchRank search results by closeness
Plagiarism detectionDetect near-duplicate passages
Record linkageMerge duplicate database entries
AutocorrectSuggest the most likely intended word
NLP / MLFeature for text similarity models

Tips

  • Case-sensitive toggle — By default, comparison is case-insensitive. Enable case-sensitivity when comparing code identifiers or passwords.
  • DP matrix — Enable “Show DP matrix” to see the full dynamic programming table with the optimal path highlighted. Limited to strings of 20 characters or fewer for readability.
  • Batch mode — Paste a list of word1,word2 pairs to compare many strings at once — handy for evaluating fuzzy-match thresholds.
  • Swap — Swap the two inputs instantly; Levenshtein distance is symmetric (d(A,B) == d(B,A)).

Compare full text blocks line by line → Text Diff Checker

Count words, characters, and sentences → Word Counter