strsim-rs

Rust implementations of string similarity metrics: Levenshtein, Jaro-Winkler, Damerau-Levenshtein, and more.

Library
Cargo
v0.11.1
494stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
39/100Needs Attention
Development Activity0
Maintenance20
Community56
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture75
Code Quality80
Innovation65
Learning Curve92

strsim (published as the strsim crate from the strsim-rs repository) is a Rust library implementing classic string similarity and edit-distance algorithms: Hamming, Levenshtein (with a normalized 0.0-1.0 variant), Optimal String Alignment, Damerau-Levenshtein (also normalized), Jaro and Jaro-Winkler, and Sørensen-Dice. Each metric ships as a plain function operating on &str inputs, plus generic versions that work over arbitrary sequences, not just strings.

Maintained under the RapidFuzz organization (which also maintains the popular rapidfuzz fuzzy-matching libraries across languages), strsim is a #[forbid(unsafe_code)] crate with no runtime dependencies, making it a lightweight building block for spell-checkers, fuzzy search, deduplication, and autocomplete features in Rust applications.

What You Get

  • levenshtein/normalized_levenshtein for edit distance and a 0.0-1.0 similarity score
  • jaro and jaro_winkler for name-matching-style similarity, tuned for short strings like names
  • damerau_levenshtein/normalized_damerau_levenshtein and osa_distance (Optimal String Alignment) for transposition-aware edit distance
  • hamming for fixed-length equal-position mismatch counts, and sorensen_dice for bigram-overlap similarity
  • Generic variants of each algorithm that operate on arbitrary sequences, not just &str

Common Use Cases

  • Fuzzy search and autocomplete features that need to rank near-matches by string similarity
  • Spell-checking and “did you mean” suggestions based on edit distance to a dictionary
  • Deduplicating near-identical records (names, addresses) using Jaro-Winkler or normalized Levenshtein thresholds
  • Data-cleaning pipelines that score and merge fuzzy-matching entries across datasets

Under The Hood

Architecture — the entire crate is a single src/lib.rs (1,303 lines) organized as one function per metric (hamming, levenshtein, osa_distance, damerau_levenshtein, jaro, jaro_winkler, sorensen_dice) plus their normalized_* and generic counterparts, with shared internal helpers for the dynamic-programming distance matrices used by the edit-distance family; there’s no module hierarchy because the crate deliberately stays flat and dependency-free. Tech Stack — pure Rust, 2021 edition, MSRV 1.56, #[forbid(unsafe_code)] with zero runtime dependencies, published under the RapidFuzz GitHub organization alongside the broader rapidfuzz fuzzy-matching family used from Python, C++, and other languages. Code Quality — a dedicated tests/lib.rs integration test suite and benches/ directory back the implementation, with CI enforcing the unsafe forbidden badge; the library is stable and mature (117 total commits, MSRV frozen at 1.56), though development activity has slowed as the API has stabilized. API Design — every metric is exposed as a plain top-level function taking two &str arguments and returning a distance or a normalized f64 similarity score, with consistent naming (normalized_* prefix for the 0.0-1.0 variants) that makes the library trivial to pick up — cargo add strsim plus one function call covers the common case, with generic variants available for non-string sequence types when needed.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search