%3C/text%3E%3C/svg%3E">
💻
💻 Tech & IT

Levenshtein Edit Distance Calculator

Results update as you type.

Your numbers

Understanding the Levenshtein edit distance calculator — concept and principle

The Levenshtein distance between two strings is the smallest number of single-character insertions, deletions and substitutions needed to turn one into the other. It is the basis of spell checkers, fuzzy search, "did you mean" suggestions, record matching and DNA sequence comparison. This calculator gives the distance and a simple similarity percentage.

Turning kitten into sittingTwo substitutions (k to s, e to i) and one insertion (g) turn kitten into sitting, so the distance is 3 and similarity 57.14%.kitten → sitting in 3 editskittensittenswap k → ssittinswap e → isittinginsert gstartEdit distance = 3similarity (1 − 3/7) = 57.14%
Three single-letter edits — two swaps and one insert — is the minimum, so the distance is 3.

How it is calculated

Let D[i][j] be the distance between the first i characters of A and the first j characters of B.

The principle

Any edit sequence ends with one of three moves on the last characters: delete A's last character, insert B's last character, or match/substitute the two. Whichever is last, the rest must be an optimal edit of shorter prefixes. So the best answer for the full strings can be built from the answers for prefixes, which is the idea of dynamic programming (Wagner–Fischer algorithm). The table has (m + 1)(n + 1) cells, giving O(mn) time; this calculator keeps only two rows, so memory is O(n).

Worked example

  1. Inputs: A = "kitten" (6 letters), B = "sitting" (7 letters).
  2. Substitute k → s: "sitten".
  3. Substitute e → i: "sittin".
  4. Insert g at the end: "sitting".
  5. No shorter sequence exists, and the table confirms the distance is 3.
  6. Similarity: (1 − 3 ÷ 7) × 100 ≈ 57.14%.

How to read the result

Distance 0 means identical strings, and the distance can never exceed the length of the longer string. For typo matching, a distance of 1 or 2 on words of normal length usually indicates the same word. The similarity percentage is a convenience score, not a standard measure; for short strings a single edit changes it a lot.

Common mistakes

Keep in mind: The calculator compares Unicode code points. Characters made of several code points, such as some emoji or decomposed accents, can count as more than one edit.

Frequently asked questions

What is a good similarity threshold?

It depends on the data; many fuzzy-search systems allow 1 edit for short words and 2 for longer ones rather than using a fixed percentage.

Is edit distance the same as Hamming distance?

Hamming distance counts only substitutions and requires equal lengths; Levenshtein also allows insertions and deletions.

Can it be computed faster than O(mn)?

If you only need to know whether the distance is at most k, banded algorithms run in about O(k · n).

Sources: V. I. Levenshtein, "Binary codes capable of correcting deletions, insertions, and reversals", Soviet Physics Doklady 10(8), 1966 · R. A. Wagner, M. J. Fischer, "The string-to-string correction problem", Journal of the ACM 21(1), 1974

Checked 8 Nov 2026. Standard formulas and RFC/IEEE definitions, computed locally in your browser — nothing you type is sent anywhere.

💻 All tech & IT tools →🌍 Calculators by country →