6 releases (3 breaking)

0.5.0 Dec 1, 2023
0.4.0 Dec 1, 2023
0.3.2 Nov 29, 2023
0.1.0 Feb 21, 2020

#96 in Text processing

Download history 311/week @ 2023-12-14 529/week @ 2023-12-21 273/week @ 2023-12-28 44/week @ 2024-01-04 27/week @ 2024-01-11 178/week @ 2024-01-18 204/week @ 2024-01-25 161/week @ 2024-02-01 229/week @ 2024-02-08 254/week @ 2024-02-15 139/week @ 2024-02-22 244/week @ 2024-02-29 317/week @ 2024-03-07 161/week @ 2024-03-14 528/week @ 2024-03-21 680/week @ 2024-03-28

1,687 downloads per month

MIT license

19K SLoC


Rapid fuzzy string matching in Rust using the Levenshtein Distance

Continous Integration Gitter chat Documentation license



RapidFuzz is a general purpose string matching library with implementations for Rust, C++ and Python.

Key Features

  • Diverse String Metrics: Offers a variety of string metrics to suit different use cases. These range from the Levenshtein distance for edit-based comparisons to the Jaro-Winkler similarity for more nuanced similarity assessments.
  • Optimized for Speed: The library is designed with performance in mind. Each implementation is carefully designed to ensure optimal performance, making it suitable for the analysis of large datasets.
  • Easy to use: The API is designed to be simple to use, while still giving the implementation room for optimization.


The installation is as simple as:

$ cargo add rapidfuzz


The following examples show the usage with the Levenshtein distance. Other metrics can be found in the fuzz and distance modules.

use rapidfuzz::distance::levenshtein;

// Perform a simple comparision using he levenshtein distance
    levenshtein::distance("kitten".chars(), "sitting".chars())

// If you are sure the input strings are ASCII only it's usually faster to operate on bytes
    levenshtein::distance("kitten".bytes(), "sitting".bytes())

// You can provide a score_cutoff value to filter out strings with distance that is worse than
// the score_cutoff

// You can provide a score_hint to tell the implementation about the expected score.
// This can be used to select a more performant implementation internally, but might cause
// a slowdown in cases where the distance is actually worse than the score_hint

// When comparing a single string to multiple strings you can use the
// provided `BatchComparators`. These can cache part of the calculation
// which can provide significant speedups
let scorer = levenshtein::BatchComparator::new("kitten".chars());
assert_eq!(3, scorer.distance("sitting".chars()));
assert_eq!(0, scorer.distance("kitten".chars()));


Licensed under either of Apache License, Version 2.0 or MIT License at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in RapidFuzz by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps