Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 4, 2026·3 min de lecture

Fuse.js — Lightweight Fuzzy-Search Library for JavaScript

A powerful, lightweight fuzzy-search library for JavaScript and TypeScript with zero dependencies, supporting weighted search, extended patterns, and flexible scoring.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Fuse.js Overview
Commande d'installation directe
npx -y tokrepo@latest install b5621511-77c5-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Fuse.js is a lightweight fuzzy-search library for JavaScript that works in both the browser and Node.js. It requires zero dependencies and enables approximate string matching so users can find results even with typos or partial queries.

What Fuse.js Does

  • Performs fuzzy (approximate) string matching on arrays of objects or strings
  • Supports weighted search across multiple keys with configurable thresholds
  • Provides extended search operators for exact match, prefix, suffix, and inverse queries
  • Works entirely client-side with no external services or network calls required
  • Returns scored and sorted results with optional match highlighting metadata

Architecture Overview

Fuse.js implements a modified Bitap algorithm for approximate string matching. When initialized, it builds an internal index of the provided data set keyed by the configured search fields. Each search query is scored against every indexed entry using configurable distance and threshold parameters, and results are ranked by relevance score.

Self-Hosting & Configuration

  • Install via npm, yarn, or pnpm; also available as a CDN script for browsers
  • Create a Fuse instance with your data array and an options object specifying keys and weights
  • Adjust the threshold option (0.0 to 1.0) to control match strictness
  • Set distance to define how far a match can be from the expected location
  • Enable includeScore and includeMatches for detailed result metadata

Key Features

  • Zero dependencies and under 15 KB minified and gzipped
  • Works identically in Node.js, browsers, and Deno
  • Extended search syntax for combining fuzzy, exact, prefix, and inverse patterns
  • Weighted multi-key search for prioritizing certain fields over others
  • Configurable scoring with threshold, distance, and location parameters

Comparison with Similar Tools

  • Lunr.js — full-text search with stemming and field boosting; heavier and requires building an index upfront
  • FlexSearch — faster for large datasets with memory-mapped indexes; more complex API surface
  • MiniSearch — similar lightweight approach with auto-suggest and prefix search built in
  • Algolia/Typesense — server-side search engines with dashboards; overkill for client-side use cases

FAQ

Q: Does Fuse.js support TypeScript? A: Yes, Fuse.js ships with built-in TypeScript type definitions.

Q: Can Fuse.js handle large datasets? A: It works well for datasets up to tens of thousands of items. For millions of records, consider a server-side search engine.

Q: Does it support async or streaming search? A: No, Fuse.js performs synchronous in-memory search. For very large lists, you can batch or paginate your data.

Q: Can I search nested objects? A: Yes, use dot notation in the keys config, such as author.name, to search nested properties.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires