Edit Distance Calculator
Measure how different two strings are by counting the single-character edits — insertions, deletions, substitutions, and transpositions — needed to turn one into the other. The Levenshtein distance (insert/delete/substitute) is the classic metric behind spell-checking, diff tools, and DNA sequence alignment; Damerau-Levenshtein adds the adjacent transposition (so ab → ba costs 1, not 2); Hamming distance counts mismatched positions in two equal-length strings. See the full dynamic-programming matrix, the optimal edit script with a character-by-character alignment, and a normalized similarity ratio. Everything runs locally in your browser.
Distances
Optimal edit script (Levenshtein alignment)
Dynamic-programming matrix (Levenshtein)
Edit distance. Build a matrix d where d[i][j] is the edit distance between the first i characters of the source and the first j of the target. Seed the borders (d[0][j] = j insertions, d[i][0] = i deletions), then fill each cell from the minimum of three neighbours: delete the source char (d[i-1][j]+1), insert the target char (d[i][j-1]+1), or substitute/match (d[i-1][j-1] + (aᵢ≠bⱼ ? 1 : 0)). The bottom-right cell is the answer, and walking back the choices yields the optimal edit script. Damerau-Levenshtein (optimal-string-alignment) adds a fourth case: when the last two characters of both prefixes are swapped, d[i][j] = min(d[i][j], d[i-2][j-2]+1). Hamming distance applies only to equal-length strings and simply counts positions that differ. The normalized similarity is 1 − Levenshtein ∕ max(|a|,|b|) (1 = identical, 0 = completely different). Pairs with the String Similarity (Jaro / Jaro-Winkler / Sørensen-Dice / Jaccard) and Soundex tools. Everything runs locally — nothing leaves your browser.