fuse.js vs fuzzy-search vs fuzzyset
Fuzzy Search Libraries
fuse.jsfuzzy-searchfuzzysetSimilar Packages:

Fuzzy Search Libraries

Fuzzy search libraries in JavaScript provide algorithms to find matches in a dataset that are similar to a given input, even if they are not exact matches. This is useful for applications like autocomplete, search suggestions, and data validation, where user input may contain typos or variations. These libraries use techniques like Levenshtein distance, tokenization, and scoring to rank results based on their similarity to the input, allowing for more flexible and user-friendly search experiences. fuse.js is a powerful, lightweight fuzzy search library that allows for searching through arrays of objects with customizable scoring and matching algorithms. fuzzy-search is a simple and fast fuzzy search library that provides a straightforward API for searching through arrays with minimal configuration. fuzzyset is a unique fuzzy matching library that creates a set of strings and uses a scoring system based on the Levenshtein distance algorithm to find and rank similar strings, making it ideal for applications that require precise control over matching accuracy.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
fuse.js020,230312 kB3a month agoApache-2.0
fuzzy-search0231-166 years agoISC
fuzzyset01,37735.6 kB14 years agosee LICENSE.md

Feature Comparison: fuse.js vs fuzzy-search vs fuzzyset

Matching Algorithm

  • fuse.js:

    fuse.js uses a combination of tokenization and weighted scoring to match input against a dataset. It allows for partial matches, supports multiple keys, and provides customizable scoring functions to prioritize certain matches over others.

  • fuzzy-search:

    fuzzy-search uses a simple fuzzy matching algorithm that allows for typos and slight variations in the input. It provides a straightforward implementation that prioritizes speed and efficiency while maintaining good accuracy in matching.

  • fuzzyset:

    fuzzyset uses the Levenshtein distance algorithm to calculate the similarity between strings. It creates a set of strings with associated scores, allowing for precise control over how matches are determined and ranked based on their similarity.

Data Structure

  • fuse.js:

    fuse.js is designed to work with arrays of objects, allowing you to specify which keys to search within each object. This makes it highly versatile for searching through complex data structures with multiple attributes.

  • fuzzy-search:

    fuzzy-search works with simple arrays of strings or objects. It provides a flexible API for searching through different types of data, but it does not require any specific structure, making it easy to integrate into various projects.

  • fuzzyset:

    fuzzyset is focused on working with a set of strings. It requires you to create a fuzzy set by adding strings to it, after which you can perform fuzzy searches and retrieve matches along with their similarity scores.

Customization

  • fuse.js:

    fuse.js offers extensive customization options, including the ability to define multiple search keys, set weights for different keys, customize the tokenization process, and define your own scoring functions. This makes it highly adaptable to different use cases and data structures.

  • fuzzy-search:

    fuzzy-search provides limited customization, focusing on simplicity and ease of use. It allows you to configure the fuzziness level and specify which keys to search, but it does not offer as much flexibility as fuse.js.

  • fuzzyset:

    fuzzyset allows for some customization in terms of how strings are added to the set and how matches are scored. However, it is more focused on providing a clear and efficient fuzzy matching process rather than offering extensive configuration options.

Performance

  • fuse.js:

    fuse.js is optimized for performance, but its complexity and the ability to handle large datasets with multiple keys can lead to slower search times compared to simpler algorithms. Performance can be improved by limiting the number of search keys and using weighted scoring to prioritize matches.

  • fuzzy-search:

    fuzzy-search is designed for fast fuzzy searching, making it suitable for applications where performance is critical. Its lightweight implementation ensures quick search times, even with larger datasets, while maintaining good accuracy.

  • fuzzyset:

    fuzzyset performance depends on the size of the string set and the complexity of the Levenshtein distance calculations. While it is efficient for smaller sets, performance may degrade with very large datasets due to the computational cost of calculating similarity scores.

Ease of Use: Code Examples

  • fuse.js:

    Fuzzy search with fuse.js

    import Fuse from 'fuse.js';
    
    const data = [
      { name: 'Alice', age: 25 },
      { name: 'Bob', age: 30 },
      { name: 'Charlie', age: 35 },
    ];
    
    const fuse = new Fuse(data, {
      keys: ['name'], // Specify the keys to search
      threshold: 0.3, // Set the fuzziness level
    });
    
    const result = fuse.search('Alic'); // Search for a fuzzy match
    console.log(result);
    
  • fuzzy-search:

    Fuzzy search with fuzzy-search

    import { fuzzySearch } from 'fuzzy-search';
    
    const data = ['apple', 'banana', 'orange', 'grape'];
    const searchTerm = 'appl';
    const results = fuzzySearch(data, searchTerm);
    console.log(results); // ['apple', 'grape']
    
  • fuzzyset:

    Fuzzy search with fuzzyset

    import FuzzySet from 'fuzzyset';
    
    const fuzzySet = FuzzySet();
    fuzzySet.add('apple');
    fuzzySet.add('banana');
    fuzzySet.add('orange');
    
    const results = fuzzySet.get('appl'); // Get fuzzy matches for 'appl'
    console.log(results);
    

How to Choose: fuse.js vs fuzzy-search vs fuzzyset

  • fuse.js:

    Choose fuse.js if you need a feature-rich fuzzy search library that supports searching through complex data structures (like arrays of objects) with customizable scoring, multiple search keys, and advanced options like tokenization and weighting. It is ideal for applications that require high accuracy and flexibility in search results.

  • fuzzy-search:

    Choose fuzzy-search if you want a lightweight and fast fuzzy search solution with a simple API. It is best for projects where performance is critical and you need a no-frills library that provides good fuzzy matching without a lot of configuration or overhead.

  • fuzzyset:

    Choose fuzzyset if you need a library that focuses on fuzzy matching with a scoring system based on Levenshtein distance. It is suitable for applications that require precise control over matching accuracy and want to work with a set of strings rather than searching through complex data structures.

README for fuse.js

Fuse.js

Node.js CI Version Downloads code style: prettier Contributors License

Fuse.js is a lightweight, zero-dependency fuzzy-search library written in TypeScript. It works in the browser and on the server, and is designed for searching small-to-medium datasets on the client side where you can't rely on a dedicated search backend.

✨ What's New: Token Search

Multi-word fuzzy search with relevance ranking. Type "javascrpt paterns" and find "JavaScript Patterns" — typo tolerance, multiple words, and smart ranking all at once.

const fuse = new Fuse(docs, {
  useTokenSearch: true,
  keys: ['title', 'author', 'description']
})

fuse.search('javascrpt paterns')
// → [{ item: { title: 'JavaScript Patterns', ... } }]

See Token Search below for details.

Installation

npm install fuse.js
yarn add fuse.js

Or include directly via CDN:

<script src="https://cdn.jsdelivr.net/npm/fuse.js/dist/fuse.min.mjs"></script>

Quick Start

import Fuse from 'fuse.js'

const books = [
  { title: "Old Man's War", author: 'John Scalzi' },
  { title: 'The Lock Artist', author: 'Steve Hamilton' },
  { title: 'HTML5', author: 'Remy Sharp' },
  { title: 'JavaScript: The Good Parts', author: 'Douglas Crockford' }
]

const fuse = new Fuse(books, {
  keys: ['title', 'author']
})

fuse.search('javscript')
// → [{ item: { title: 'JavaScript: The Good Parts', ... }, ... }]

Features

Fuzzy Search

The core of Fuse.js. Uses the Bitap algorithm for approximate string matching — handles typos, misspellings, and partial matches out of the box.

fuse.search('javscript')
// → [{ item: { title: 'JavaScript: The Good Parts', author: 'Douglas Crockford' } }]

Weighted Keys

Search across multiple fields with different importance levels. Title matches can rank higher than description matches.

const fuse = new Fuse(docs, {
  keys: [
    { name: 'title', weight: 2 },
    { name: 'description', weight: 1 }
  ]
})

Extended Search

Use operators for precise control: exact match (=), prefix (^), suffix (!), and more. Enable with useExtendedSearch: true.

const fuse = new Fuse(list, {
  useExtendedSearch: true,
  keys: ['title']
})

fuse.search('=exact match')   // exact match
fuse.search('^prefix')        // starts with
fuse.search('!term')          // does not include

Token Search

Splits multi-word queries into individual terms, fuzzy-matches each independently, and ranks results using BM25-style IDF weighting. Enable with useTokenSearch: true.

const fuse = new Fuse(docs, {
  useTokenSearch: true,
  keys: ['title', 'body']
})

fuse.search('express midleware rout')
// Finds "Express Middleware" and "Express Routing Guide" despite typos
  • Typo tolerance per word — each term is fuzzy-matched independently
  • Relevance ranking — rare terms are weighted higher than common ones
  • Word order independent"patterns javascript" and "javascript patterns" return identical results
  • No query length limit — long multi-word queries work naturally since each term is searched separately

Available in the full build. See TOKEN_SEARCH.md for details and performance benchmarks.

Logical Search

Combine conditions with $and and $or for complex queries. Available in the full build.

fuse.search({
  $and: [
    { title: 'javascript' },
    { author: 'crockford' }
  ]
})

Match Highlighting

Get character-level match indices for highlighting search results in your UI.

const fuse = new Fuse(list, {
  includeMatches: true,
  keys: ['title']
})

const result = fuse.search('javscript')
// result[0].matches[0].indices → [[0, 9]]

Single String Matching

Use Fuse.match() to fuzzy-match a pattern against a single string without creating an index. Useful for one-off comparisons or custom filtering.

const result = Fuse.match('javscript', 'JavaScript: The Good Parts')
// → { isMatch: true, score: 0.04, indices: [[0, 9]] }

Dynamic Collections

Add and remove documents from a live index without rebuilding.

fuse.add({ title: 'New Book', author: 'New Author' })
fuse.remove((doc) => doc.title === 'Old Book')

Builds

Fuse.js ships in two variants:

BuildIncludesMin + gzip
FullFuzzy + Extended + Logical + Token search~8 kB
BasicFuzzy search only~6.5 kB

Use the basic build if you only need fuzzy search and want the smallest bundle size.

Documentation

For the full API reference, configuration options, scoring theory, and interactive demos, visit fusejs.io.

Supporting Fuse.js

Develop

See DEVELOPERS.md for setup, scripts, and project structure.

Contribute

See CONTRIBUTING.md for guidelines on issues and pull requests.