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
- Type or paste two strings.
- Read off each distance metric and the similarity %.
- 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
URL Slug Generator
Turn any text into a clean URL slug — strip accents, choose a separator, set a max length.
Markdown Table Generator
Paste CSV, TSV, or pipe-delimited data and get a properly aligned GitHub-flavored Markdown table.
Text Diff Viewer
Compare two pieces of text and see line-by-line or word-by-word additions and removals.
Lorem Ipsum Generator
Generate placeholder text by paragraphs, sentences, or words.
Case Converter
Convert text between UPPER, lower, Title, camelCase, snake_case and more.
Character & Word Counter
Count characters, words, sentences, lines, and bytes in real time.