Fuse.js
A "fuzzy search" tool that helps users find what they are looking for even if they make a typo or spell a word wrong.
Fuse.js
General JSA "fuzzy search" tool that helps users find what they are looking for even if they make a typo or spell a word wrong.
Fit
Bundle (gzip)
9.2 kB
25.9 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Implementing an effective fuzzy search from scratch is a complex technical challenge that often feels out of reach for beginners, as it requires handling intricate string-matching algorithms and scoring logic. This difficulty is amplified when your data lives in a static JSON file rather than a database, leaving you without built-in search tools to manage approximate matches or typos. Beyond just making the search work, there is the ongoing struggle of maintaining a great developer experience—finding a solution that is easy to integrate and configure without turning your codebase into a mess of custom search functions.
What It Does
Fuse.js provides a powerful, lightweight solution for approximate string matching without the need for a complex backend or custom algorithmic code. It solves the difficulty of manual implementation by offering a simple, intuitive API that works perfectly with local JSON data, allowing users to find what they need even with typos or misspellings. By focusing on a superior developer experience, it enables you to deploy professional-grade search functionality instantly, ensuring your application remains fast and user-friendly while keeping your development process clean and efficient.
Installation
npm i fuse.jsUsage Example
Import the library and define the search configuration :
import Fuse from "fuse.js";
const books = [
{ title: "Old Man's War", author: "John Scalzi" },
{ title: "The Lock Artist", author: "Steve Hamilton" },
{ title: "JavaScript Patterns", author: "Stoyan Stefanov" },
];
const fuse = new Fuse(books, {
keys: ["title", "author"],
includeScore: true,
});
fuse.search("jon");
// [{ item: { title: "Old Man's War", author: "John Scalzi" }, refIndex: 0, score: 0.25 }]Related packages
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
archiverGeneral JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.