fuse.js vs fuzzy-search vs fuzzysort
Fuzzy Search Libraries for Frontend Applications
fuse.jsfuzzy-searchfuzzysortSimilar Packages:

Fuzzy Search Libraries for Frontend Applications

fuse.js, fuzzy-search, and fuzzysort are JavaScript libraries designed to perform approximate string matching, commonly known as fuzzy search. They allow users to find relevant results even when typos occur or when the search query does not exactly match the data. fuse.js is a full-featured search engine with weighted scoring and deep configuration. fuzzysort focuses on raw speed and simplicity with a small footprint. fuzzy-search offers a basic implementation often used for simple list filtering with minimal setup.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
fuse.js020,454417 kB1a month agoApache-2.0
fuzzy-search0229-167 years agoISC
fuzzysort04,34478.9 kB710 days agoMIT

Fuzzy Search Libraries: fuse.js vs fuzzy-search vs fuzzysort

When building search features in web applications, exact matching is rarely enough. Users make typos, forget words, or type partial strings. fuse.js, fuzzy-search, and fuzzysort solve this by allowing approximate matching, but they differ significantly in speed, features, and API design. Let's break down how they handle real-world search scenarios.

๐Ÿ› ๏ธ Setup and Initialization

fuse.js requires creating an instance with your data and configuration options.

  • You define which keys to search and how strict the matching should be.
  • Supports nested properties and weighted keys out of the box.
// fuse.js: Initialize with options
import Fuse from 'fuse.js';

const options = {
  keys: ['title', 'author'],
  threshold: 0.3
};
const fuse = new Fuse(bookList, options);

fuzzy-search uses a similar constructor pattern but with fewer options.

  • You pass the list and keys directly to the constructor.
  • Less configuration means faster setup but less control.
// fuzzy-search: Initialize with list and keys
import FuzzySearch from 'fuzzy-search';

const searcher = new FuzzySearch(bookList, ['title', 'author']);

fuzzysort does not require an instance.

  • You call the search function directly with your data.
  • This reduces boilerplate and keeps the code functional.
// fuzzysort: Direct function call
import fuzzysort from 'fuzzysort';

// No instance needed, pass data directly to search
const results = fuzzysort.search('query', bookList, { keys: ['title', 'author'] });

๐Ÿ” Search Execution and Configuration

fuse.js offers deep configuration for relevance tuning.

  • You can adjust sensitivity, ignore location, and boost specific fields.
  • Great for when some fields matter more than others.
// fuse.js: Search with custom threshold
const results = fuse.search('harry potter', { limit: 10 });
// Options like threshold can be set during init or search

fuzzy-search keeps execution simple with minimal arguments.

  • You pass the query string and optionally a limit.
  • Lacks advanced tuning like field boosting.
// fuzzy-search: Simple search call
const results = searcher.search('harry potter', 10);
// Returns matching items directly

fuzzysort balances speed with some configuration options.

  • You can set thresholds and limits directly in the search call.
  • Focuses on performance while allowing basic control.
// fuzzysort: Search with options
const results = fuzzysort.search('harry potter', bookList, {
  limit: 10,
  threshold: -1000
});
// Returns objects with score and match data

๐Ÿ“ฆ Result Structure and Scoring

fuse.js returns detailed match information including scores.

  • Each result includes the item, match score, and matched indices.
  • Useful for highlighting matches or sorting by relevance.
// fuse.js: Rich result object
// result.item -> original data
// result.score -> relevance score (lower is better)
// result.matches -> details on which keys matched
console.log(results[0].score);

fuzzy-search returns the original items by default.

  • Simpler output but less info on why something matched.
  • You may need to calculate relevance separately if needed.
// fuzzy-search: Returns original items
// results is an array of the original objects
console.log(results[0]); // Direct access to item

fuzzysort returns objects with score and target data.

  • Includes the score and the matched string segments.
  • Designed for easy highlighting and sorting.
// fuzzysort: Result with score and highlights
// result.score -> numeric score (higher is better)
// result.obj -> original item
console.log(results[0].score);

โšก Performance and Maintenance

fuse.js is actively maintained and widely adopted.

  • Regular updates ensure compatibility with modern build tools.
  • Slightly heavier due to feature richness but stable for production.
// fuse.js: Actively maintained
// Suitable for long-term enterprise projects
import Fuse from 'fuse.js'; // Standard import

fuzzy-search has less frequent updates and community activity.

  • Works well for simple needs but may lack modern features.
  • Consider verifying maintenance status before committing to large projects.
// fuzzy-search: Simpler maintenance profile
// Check npm page for recent updates before use
import FuzzySearch from 'fuzzy-search';

fuzzysort is optimized for speed and written in TypeScript.

  • Very fast on large datasets due to optimized algorithms.
  • Active maintenance with a focus on performance improvements.
// fuzzysort: High performance focus
// Ideal for command palettes and large lists
import fuzzysort from 'fuzzysort';

๐Ÿ“Œ Summary Table

Featurefuse.jsfuzzy-searchfuzzysort
SetupInstance with optionsInstance with keysDirect function call
ConfigHigh (weights, threshold)Low (basic)Medium (threshold, limit)
ResultsItem + Score + MatchesItem onlyItem + Score + Highlights
SpeedModerateModerateVery Fast
MaintenanceActiveLess ActiveActive

๐Ÿ’ก Final Recommendation

fuse.js is the safest choice for most applications โ€” it balances features, stability, and community support. Use it when search relevance is critical and you need to tune how matches are scored.

fuzzysort is the performance specialist โ€” pick it for command palettes, large datasets, or when every millisecond counts. Its TypeScript support is a bonus for modern stacks.

fuzzy-search is the lightweight option โ€” suitable for small tools or legacy code where adding a heavier library is not worth it. For new projects, prefer fuse.js or fuzzysort for better long-term support.

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

  • fuse.js:

    Choose fuse.js if you need advanced features like weighted search keys, nested object support, and customizable scoring thresholds. It is the industry standard for complex search requirements where accuracy and configuration matter more than raw speed. Ideal for documentation sites, large datasets, and applications needing fine-tuned relevance.

  • fuzzy-search:

    Choose fuzzy-search if you need a very simple, lightweight solution for small lists and do not require advanced weighting or scoring. It works well for legacy projects or quick prototypes where adding a heavier dependency is not justified. Avoid for large-scale applications needing high performance or complex matching rules.

  • fuzzysort:

    Choose fuzzysort if performance is your top priority and you need fast results on large lists without complex configuration. It is perfect for command palettes, quick filters, and TypeScript projects that benefit from its built-in types. Best when you need speed over advanced weighting features.

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.

Web Workers

Search large datasets without freezing the UI. FuseWorker splits your data across multiple Web Workers and searches in parallel โ€” ~5x faster on 100K documents.

import { FuseWorker } from 'fuse.js/worker'

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

const results = await fuse.search('query')
fuse.terminate()

Same options and results as Fuse โ€” just async. Function-valued options (sortFn, getFn, keys[].getFn) aren't supported because functions can't be transferred to a worker; everything else carries over. See the Web Workers docs for the interactive demo and full API.

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
  • AND or OR โ€” tokenMatch: 'all' returns only records matching every word (filtering); the default 'any' matches any word
  • Custom tokenizer โ€” pass a regex or function via tokenize for tokens with internal punctuation (node.js, c++), or use Intl.Segmenter for CJK / Thai word segmentation. Unicode-aware by default

Available in the full build. See the Token Search docs 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]] }

Fuse.match() does not support useTokenSearch โ€” token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison can't provide. Passing useTokenSearch: true throws an explicit error. Use new Fuse(docs, { useTokenSearch: true }).search(query) for token-search behavior.

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.6 kB
BasicFuzzy search only~6.8 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.

Official ports

  • fuse-swift: Swift port for iOS, macOS, tvOS, watchOS, visionOS, and Linux. Byte-equivalent results, idiomatic Swift API, syncs with each upstream release. Currently in 2.0.0-rc.1.

Supporting Fuse.js

Develop

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

Contribute

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