# 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. ## Install Save as a script file and run: # Fuse.js — Lightweight Fuzzy-Search Library for JavaScript ## Quick Use ```bash npm install fuse.js ``` ```js import Fuse from 'fuse.js'; const fuse = new Fuse([{title: 'Old Man'}, {title: 'The Old Sea'}], {keys: ['title']}); console.log(fuse.search('old')); ``` ## 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 - https://github.com/krisk/Fuse - https://www.fusejs.io/ --- Source: https://tokrepo.com/en/workflows/asset-b5621511 Author: Script Depot