String Similarity (Levenshtein)
Compare two strings and see Levenshtein edit distance, similarity score, and step-by-step operations.
How it works
- 1
Enter two strings
Type or paste the two strings you want to compare.
- 2
Review the results
See the edit distance, similarity percentage, and color-coded edit operations.
- 3
Explore the matrix
For short strings, expand the distance matrix to see the full dynamic programming table.
Common use cases
Classic example
kitten → sitting
Identical strings
hello → hello
About This Tool
Enter two strings and instantly see the Levenshtein edit distance -- the minimum number of single-character insertions, deletions, and substitutions needed to transform one string into the other. The tool also shows a percentage similarity score, a color-coded list of edit operations, and (for short strings) the full dynamic programming matrix.
The similarity percentage is calculated as: (maxLength - distance) / maxLength × 100. A distance of 0 means the strings are identical (100% similar). Higher distances indicate more differences.
Use cases include: fuzzy string matching for search suggestions, typo detection in form validation, comparing DNA/protein sequences, evaluating OCR accuracy, measuring how similar two text snippets are, and testing data deduplication logic.
The algorithm runs in O(n×m) time where n and m are the string lengths. For very long strings (1000+ characters), computation may take a moment. All processing is client-side.
More examples
Examples
Classic example
Input
kitten → sitting
Output
Distance: 3, Similarity: 57.1%, Ops: Substitute k→s, Keep i, Keep t, Keep t, Substitute e→i, Keep n, Insert g
Identical strings
Input
hello → hello
Output
Distance: 0, Similarity: 100%
Frequently Asked Questions
- What is Levenshtein distance?
- The Levenshtein distance between two strings is the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other. It was developed by Vladimir Levenshtein in 1965.
- How is the similarity percentage calculated?
- Similarity % = (maxLength - distance) / maxLength × 100. If two 7-character strings have a distance of 3, similarity is (7-3)/7 = 57.1%.
- Is the comparison case-sensitive?
- By default yes. Toggle the case-sensitive option off to compare strings in a case-insensitive manner (both are lowercased before comparison).
- What is the distance matrix?
- The matrix shows the dynamic programming table used to compute the edit distance. Each cell [i][j] represents the minimum edits to transform the first i characters of String A into the first j characters of String B. The bottom-right cell is the final distance.
Discover More Tools
View all Developer Tools →Text Diff Tool
Compare two texts and see differences highlighted line by line.
Regex Tester
Test and debug regular expressions with real-time matching.
Word & Character Counter
Count words, characters, sentences, and paragraphs in real time.
JSON Formatter & Validator
Format, validate, and prettify JSON instantly.