| name | fusejs |
| description | Implement fuzzy search in JavaScript/TypeScript projects using Fuse.js. Use when users need client-side search, fuzzy matching, search highlighting, multi-field weighted search, tokenized search, or Web Worker parallel search. |
Fuse.js Fuzzy Search
A zero-dependency TypeScript library based on the Bitap algorithm. Works in browsers, Node.js, and Deno.
Installation
npm install fuse.js
npm install fuse.js@beta
import Fuse from 'fuse.js'
import Fuse from 'fuse.js/basic'
Minimal Example
const fuse = new Fuse(list, {
keys: ['title', 'author'],
includeScore: true,
threshold: 0.4,
})
fuse.search('jon')
Usage by Scenario
Fuzzy Search (Basic)
new Fuse(list, {
keys: ['name'],
threshold: 0.4,
ignoreLocation: true,
includeMatches: true,
includeScore: true,
minMatchCharLength: 2,
})
Multi-field Weighted Search
keys: [
{ name: 'title', weight: 2 },
{ name: 'description', weight: 1 },
]
Dot notation: 'author.firstName'. Set ignoreFieldNorm to disable the short-field bonus.
Extended Search (Operators)
{ useExtendedSearch: true }
fuse.search('^java =exact')
fuse.search("!deprecated | 'active")
Operators: no prefix=fuzzy, ==exact, '=contains, !=exclude, ^=prefix, .$=suffix. Requires Fuse.use(ExtendedSearch) for the basic version.
Tokenized Search
{
useTokenSearch: true,
tokenMatch: 'any'
}
Multi-word queries are split into independent tokens for fuzzy matching + IDF weighting. Word order is irrelevant, and there is no 32-character length limit. Use the tokenize function + Intl.Segmenter for CJK tokenization. Full version only.
Logical Queries
fuse.search({
$and: [{ title: 'js' }, { $or: [{ author: 'a' }, { author: 'b' }] }]
})
Highlighting
includeMatches: true → result.matches[].indices → [[start, end], ...]. Note: end is inclusive.
Dynamic Add/Remove & Single Matching
fuse.add(doc)
fuse.remove(doc => doc.id === 'x')
Fuse.match('patern', 'pattern matching')
Web Worker (Large Datasets)
import { FuseWorker } from 'fuse.js/worker'
const fuse = new FuseWorker(docs, { keys: ['title'] })
const r = await fuse.search('q')
fuse.terminate()
With 4 workers + 100K documents: approximately 3.3x speedup. Browser only. Does not support sortFn/getFn/useTokenSearch.
Reference Documentation
Load as needed:
- options — Complete options API
- examples — Practical patterns and scenario quick reference
- react — React components: debouncing, highlighting, virtualization
- performance — Benchmark data and optimization guide
- vs-semantic — Comparison with semantic search and selection guide
Important Notes
- Default search only looks at the first ~60 characters of a field → Use
ignoreLocation: true for long text.
- Bitap has a single-pattern limit of 32 characters → Use
useTokenSearch for long queries.
- FuseWorker is browser only. The
search() method returns a Promise. Does not support function options.
- Score: 0 = perfect match, 1 = no match.
- The basic version does not include extended search or tokenized search.