Levenshtein Distance Calculator
Calculate the Levenshtein edit distance between two strings, the minimum number of insertions, deletions and substitutions to transform one into the other.
Last reviewed by the Radiatus Cloud team
Calculate the Levenshtein edit distance between two strings.
Securing AI in production?
We build guardrails, governance & compliance for AI systems.
Calculate edit distance
The Levenshtein distance, also called the edit distance, is the minimum number of single-character edits, insertions, deletions or substitutions, needed to change one string into another. This calculator computes it for any two strings and derives a similarity percentage from the distance relative to the longer string. For example, transforming kitten into sitting takes three edits, so their Levenshtein distance is three.
The algorithm uses dynamic programming, filling a grid that compares the two strings character by character to find the cheapest sequence of edits.
Where edit distance is used
Levenshtein distance underpins spell checkers, fuzzy search, autocorrect, DNA sequence comparison and record matching, anywhere the closeness of two strings matters. In natural language and AI work it is used to compare generated text with references and to deduplicate near-identical strings. The derived similarity percentage makes the raw distance easier to interpret across strings of different lengths.
Because it counts the actual edits rather than just differences, Levenshtein distance captures the real effort to reconcile two strings. All calculation happens locally in your browser.
Notes on these estimates
Because the levenshtein distance calculator runs entirely in your browser, nothing you enter is uploaded, so you can use it with private data safely. The figures are estimates based on the values you provide and common rules of thumb, so treat them as planning guidance rather than exact measurements, and run the tool as often as you need for free.
Related tools
- AI Prompt Leakage Analyzer — Paste a system prompt and a hostile user input to see whether the prompt holds secrets and whether the input carries injection patterns. Local, instant.
- LLM Data Exposure Checker — Check if text contains data likely to be memorized or exposed by LLMs.
- AI Usage Policy Generator — Generate an acceptable use policy for AI tools in your company.
- Model Hallucination Estimator — Estimate risk of hallucinations based on task type and temperature.
Frequently Asked Questions
What is Levenshtein distance?
It is the minimum number of insertions, deletions and substitutions of single characters needed to turn one string into another.
How is the similarity percentage calculated?
It is one minus the distance divided by the length of the longer string, giving a value that is easy to compare across different string lengths.
What is it used for?
Spell checking, fuzzy search, autocorrect, record matching and comparing generated text with references, among many applications.
How does it differ from Hamming distance?
Hamming distance only counts substitutions and needs equal-length strings, while Levenshtein also allows insertions and deletions for any lengths.
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Enter two strings to compute their edit distance and similarity.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.
Related Tools
AI Prompt Leakage Analyzer
AI SecurityPaste a system prompt and a hostile user input to see whether the prompt holds secrets and whether the input carries injection patterns. Local, instant.
LLM Data Exposure Checker
AI SecurityCheck if text contains data likely to be memorized or exposed by LLMs.
AI Usage Policy Generator
AI SecurityGenerate an acceptable use policy for AI tools in your company.