fuzzysort ranks Sublime-style matches in plain JavaScript, and snapshot() is where the speed lives
Fast SublimeText-like fuzzy search for JavaScript.
At a glance
- What is it?
- fuzzysort is a single-file fuzzy matcher with no runtime dependencies, aimed at file pickers, command palettes and typeahead fields that run in the browser. It is fast and tiny, so the interesting decisions sit in how you feed it targets, not in the API surface.
- Who is it for?
- Adopt fuzzysort when the target list fits in memory and you want one ranking pass with no index to maintain: a file picker, a command palette, a filter over a few thousand strings. Do not adopt it if you need typo-aware matching on free text, a persisted index, or a ranked search across fields it cannot normalize away.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 105 days ago.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Star history
- farzher/fuzzysort4,353 ★ · +1
| Repository | 2026-09-23 | 2026-11-25 |
|---|---|---|
| farzher/fuzzysort | 4.4k | 4.4k |
1 Stars in the last 63 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
A greedy matcher for pickers and palettes, not a search engine
fuzzysort answers one question fast: given a list of strings or objects and a short query, which entries should rank highest. That is the Sublime Text file-opener problem. You type `ui` and it has to decide between `Guide.cpp` and `UserInterface.cpp` without building an index, without a server and without a dependency tree.
The package ships one readable source file, `fuzzysort.js`, and a minified twin, plus `index.d.ts` for types. There are no runtime dependencies; `terser` is a devDependency used by the `minify` script. Everything the matcher knows about your data lives in the `keys` option.
That narrowness is the point and also the limit. There is no tokenizer, no stemming, no field boosting beyond a `scoreFn` callback, and no persistence layer. If your search surface is a dropdown over a known set of rows, this is a good fit. If it is full-text retrieval over documents, this is the wrong shape of tool.
threshold and limit silently reshape what a query returns
Every search goes through `go()`, and the option list is short enough to read in one glance:
fuzzysort.go(search, targets, {
limit : 10, // Max results; 0 = unlimited
threshold : .5, // Minimum score; 0 = any match
key : null, // Search one property
keys : null, // Search multiple properties
scoreFn : null, // Override result scoring
})Two of those defaults will change your results without warning you. `limit` truncates the array, so a query that matches 400 rows hands back 10. `threshold` is described as a minimum score where 0 means any match, and since v4.0.0 a default is applied, so a query that would once have returned everything now returns only the plausible matches.
Scores run from 0 to 1, and the docs call 1 a perfect match and 0.5 a good match.
snapshot() converts a per-query preparation cost into a one-time cost
The largest speed lever is not the matching algorithm, it is whether you re-prepare every target on every keystroke. If your targets never change, `snapshot()` builds an immutable prepared form once:
targets = fuzzysort.snapshot(targets, {key: 'file'})
fuzzysort.go('gotta', targets)
fuzzysort.go('go', targets)
fuzzysort.go('fast', targets)The snapshot is tied to the keys you passed at creation time. The same effect is available without a snapshot by preparing each field yourself and pointing `key` at the prepared property:
targets.forEach(t => t.filePrepared = fuzzysort.prepare(t.file))
fuzzysort.go('fast', targets, {key: 'filePrepared'})The documentation also tells you to filter out targets you do not want searched, naming long ones in particular.
NFKD normalization plus remap() decide what a query can even match
Matching happens on a normalized form of both query and target: NFKD normalization, diacritics stripped, and a built-in table that folds common quote, dash, slash, ellipsis and lookalike characters onto one another.
The table is not fixed. `remap()` adds or overrides entries:
fuzzysort.remap({',': '.'}) // 12,5 = 12.5This is the single most project-specific thing about the matcher and also the easiest to get wrong. The mapping is global, not per search, so a remap that helps one dataset changes scoring for every query in the process. Nothing documents how to reset the table to defaults, and nothing warns that an override replaces the built-in character rather than adding a synonym alongside it.
npm for bundlers, a pinned ESM URL for a page with no build step
The install path is one command:
npm i fuzzysortand the import is a default import of an ES module, which matches `"type": "module"` in `package.json`:
import fuzzysort from 'fuzzysort'A page with no bundler loads the minified build straight from a CDN, pinned to a version:
<script type="module">
import fuzzysort from 'https://cdn.jsdelivr.net/npm/[email protected]/fuzzysort.min.js'
</script>One packaging detail to check: `"main": "fuzzysort.js"` points at the unminified file, so a consumer that resolves the default entry gets the readable source rather than `fuzzysort.min.js`. The `files` array publishes both. Pinning the URL in the browser snippet is the safer route if you care about bytes.
Structured cloning in a Web Worker drops the getters on every result
Move a search into a Web Worker and the results arrive through structured cloning, which does not preserve the accessor properties `single()` returns. Calling `result.highlight(...)` after the transfer fails.
The fix is module-level helpers that accept a cloned result:
fuzzysort.score(result)
fuzzysort.highlight(result)A second surprise sits in the v4.0.0 changelog: `options.all` was removed and an empty search now returns results rather than nothing. Combined with the default `limit`, an empty query box quietly produces a truncated list instead of an empty one.
uFuzzy filters the candidate set, fuzzysort scores all of it
fuzzysort's performance advice is practical: filter your target list yourself, snapshot it, or prepare fields yourself. That is a better fit when the candidate set is already small and known, which is the file picker case.
Editorial conclusion
Adopt fuzzysort when the target list fits in memory and you want one ranking pass with no index to maintain: a file picker, a command palette, a filter over a few thousand strings. Do not adopt it if you need typo-aware matching on free text, a persisted index, or a ranked search across fields it cannot normalize away. Before shipping, filter out long targets you do not need to search, as the README's performance tips advise, and decide whether a fuzzy match at score 0.5 is acceptable in your interface.
Frequently asked questions
What is fuzzysort and what is it used for?
fuzzysort is a dependency-free JavaScript library that ranks Sublime-style fuzzy matches, described in its package description as fast SublimeText-like fuzzy search for JavaScript. It targets pickers, palettes and typeahead fields over lists of strings or objects.
How do I use fuzzy search in JavaScript with fuzzysort?
Import the module and call `fuzzysort.go(search, targets, options)`. Searching a list of objects with `key: 'file'` returns results whose `.obj` points back at your original object.
What does fuzzysort.snapshot() do and when should I use it?
It creates an immutable prepared version of your targets for repeated searching, which the documentation recommends when targets do not change. It was added in v4.0.0 together with `score()` and `highlight()` for Web Worker support.
Why does result.highlight() fail inside a Web Worker?
Structured cloning can remove the getters on results, so the instance method is gone after the transfer. Use the module-level `fuzzysort.score(result)` and `fuzzysort.highlight(result)` for cloned results.
Can fuzzysort search multiple fields of the same object?
Yes, through the `keys` option, which can hold property names and functions such as `obj => obj.tags?.join()`. The `scoreFn` option then reweights results, for example doubling the score for a favourite item.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/farzher-fuzzysort)Star history chart for your README
[](https://hysenlabs.com/projects/farzher-fuzzysort)Was this useful?