Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsJul 4, 2026·3 min de lectura

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.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Fuse.js Overview
Comando de instalación directa
npx -y tokrepo@latest install b5621511-77c5-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con 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

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados