Levenshtein Distance — Compare Two Strings

Compute edit distance & similarity and see a highlighted visual diff. Private by design—everything runs locally.

Input & Options

A: 0 chars · B: 0 chars

Tips: Ctrl/Cmd + K focuses “A”. Ctrl/Cmd + Enter runs Compare.

Results

Distance:
Similarity:
Ops:
Lengths:
Deletion (A only) Insertion (B only) Substitution

A with changes highlighted

B with changes highlighted

Show aligned operations

    Understand how similar two strings are

    When two pieces of text look almost the same, it helps to have a clear way to measure how different they really are. The Levenshtein distance calculator does exactly that. It compares two strings and tells you the smallest number of changes needed to turn one into the other. This makes it a handy tool for anyone who wants a quick, objective measure of similarity.

    The idea behind edit distance

    Levenshtein distance is also called edit distance because it counts simple editing steps: inserting a character, deleting a character, or replacing one character with another. If you change kitten to sitting, you need three edits, so the distance is 3. A lower distance means the strings are more alike; a higher distance means they are more different.

    Character mode vs. word mode

    This tool lets you compare at the character level or at the word level. Character mode is best for short strings, product codes, usernames, or spelling mistakes. Word mode splits on spaces and compares whole words, which is easier to understand for sentences and paragraphs. It answers a more human question: how many word-level changes are needed?

    How to use the calculator

    1. Paste or type your first text into the A box.
    2. Paste or type your second text into the B box.
    3. Select character or word mode, depending on your goal.
    4. Adjust case sensitivity if you want “Apple” and “apple” treated as the same.
    5. Review the distance, similarity score, and highlighted differences.

    Why it is useful in real life

    • Spell checking and fuzzy search: find results that are close to what a user typed.
    • Data cleanup: spot near-duplicate names, addresses, and product titles.
    • Content review: compare two versions of a sentence or paragraph.
    • Customer support and forms: tolerate typos while matching inputs.

    Similarity score in plain language

    Along with the distance, the tool shows a similarity percentage. This is a simple way to see how close two strings are relative to their length. A higher percentage means the texts are more alike. In word mode, the length is based on word count rather than characters.

    Privacy and display details

    Everything runs in your browser, so your text stays private. The comparison highlights the edits so you can see exactly where differences occur. This makes the tool useful as a quick string similarity checker, a text comparison helper, or an edit distance calculator for everyday tasks.

    5 Fun Facts about Levenshtein Distance

    DNA to typos

    The same edit-distance math powers spellcheckers and genetic alignment—letters or nucleotides, it’s edits all the way down.

    Dual purpose

    1965 origin story

    Vladimir Levenshtein introduced the metric for error-correcting codes; the internet later turned it into fuzzy search fame.

    Paper roots

    Transposition needs a cousin

    Plain Levenshtein counts “teh”→“the” as two edits. Damerau–Levenshtein treats that swap as one.

    Swap-aware

    Similarity ≠ distance

    Distance is raw edits; similarity scales by length. One edit in a 3-letter word hurts more than one edit in a 30-letter string.

    Scale matters

    DP is the engine

    A dynamic-programming grid finds the minimum edits in O(m·n). The highlighted path is the story of how A becomes B.

    Algorithm core

    Explore more tools