AZ Tools

String Distance Calculator

Text

Type two strings and see how far apart they are by several edit-distance metrics. **Levenshtein** counts insertions, deletions, and substitutions — the classic spell-check metric. **Damerau-Levenshtein** also counts adjacent transpositions as one edit, which matches typing typos better. **Hamming** counts position-by-position differences (only defined when both strings are the same length). The **similarity percentage** is `(1 - levenshtein / max_length) * 100`, useful as a fuzzy-match threshold for deduping records.

Similarity

57.1%

Levenshtein

3

Damerau-Lev.

3

Hamming

n/a

Damerau-Levenshtein treats `ab → ba` (transposition) as one edit; plain Levenshtein counts it as two. Hamming only works for equal-length strings.

How to use

  1. Type or paste two strings.
  2. Read off each distance metric and the similarity %.
  3. Use ~85%+ similarity as a starting threshold for fuzzy deduplication, lower for typo-tolerant search.

Frequently asked questions

Which metric should I use?
For typed text where humans transpose adjacent characters, use Damerau-Levenshtein. For protein sequences or fixed-length codes use Hamming. For everything else (URL slugs, names, free text) Levenshtein is the safe default — and what most spell-check libraries use internally.
How does similarity % relate to the distances?
It's a normalized Levenshtein: 100% means identical, 0% means every character has to be replaced. The denominator is the longer of the two strings, so `cat` vs `dog` is 0% (3 edits / 3 chars) but `cat` vs `catt` is 75% (1 edit / 4 chars).
Why is Hamming sometimes 'n/a'?
Hamming distance is only defined for equal-length strings. If lengths differ, there's no meaningful pairwise position comparison — use Levenshtein instead.
Is this case-sensitive?
Yes. `Cat` vs `cat` has Levenshtein distance 1. Lowercase both inputs first if you want case-insensitive comparison.

Related tools