
fuzzy-toolkit
io.github.Tfoucher5/fuzzy-toolkit
Fuzzy matching for agents: compare, search, dedupe, match lists, find names, map fields, fix JSON.
Documentation
fuzzy-toolkit
Close enough is a match.
Fuzzy string matching for JavaScript and TypeScript: typos, accents, word order, numbers in words and noise are handled for you, in about 10 kB with zero dependencies.
Documentation · Getting started · Playground · API · Benchmarks · Coming from another library
npm install fuzzy-toolkit
import { check, search, closest, find, dedupe } from 'fuzzy-toolkit'
check('bohemian rapsody', 'Bohemian Rhapsody') // { verdict: 'correct', score: 94.12 }
search('new yo', cities, { preset: 'search' }) // New York, New York City
closest('pyhton', ['python', 'java', 'php'])?.item // 'python'
find("je crois que c'est bohemian rapsody", 'Bohemian Rhapsody') // where it is in the text
dedupe(['Beyoncé', 'beyonce', 'Adele']) // ['Beyoncé', 'Adele']
Scores go from 0 to 100, and the default threshold is 80.
Why fuzzy-toolkit
- Right by default. On 3,000 simulated blind-test guesses, 97.6% of right answers were accepted and 0% of wrong ones.
- One function per job. Grade answers (
check), search as you type (createIndex), suggest corrections (closest), spot names in a message (find,findAll), clean data (dedupe,standardize,join), map CSV headers to your schema (mapFields), repair what a model returned (repair), show what was misspelled (diff). - Finds more, waits less. On song titles with typos it finds more than Fuse.js, 13 times faster (benchmarks).
- Speaks 6 languages. Numbers in words, articles and sounds in English, French, Spanish, German, Italian and Dutch, plus your own packs.
- Small and typed. About 10 kB (min+gzip) for the usual imports, no dependencies, ESM and CommonJS, Node 18+, Bun, Deno and every browser. Every option autocompletes.
- More than a library. React, Vue and Svelte helpers, a Web Worker for huge lists, a command line tool for CSV files, and an MCP server for AI agents.
Coming from string-similarity
string-similarity is no longer maintained. Change the import, nothing else: same functions, same results, faster.
const stringSimilarity = require('fuzzy-toolkit/string-similarity')
Coming from Fuse.js
Change the import, keep the code: fuzzy-toolkit/fuse has the Fuse.js API (new Fuse(list, options).search(query)), with fuzzy-toolkit doing the matching. On song titles typed with a typo, the same code finds 80 % of them instead of 65 %, 15 times faster. What differs.
import Fuse from 'fuzzy-toolkit/fuse'
Learn more
| Getting started | Install, first match, objects and options |
| Recipes | Quizzes, search boxes, "did you mean", data cleaning, command line, AI agents |
| Languages and presets | Add a language or a preset for your kind of data |
| API reference | Every function and option |
| Upgrading from v1 | Formerly guess-rater: what changed |
FAQ
What can replace string-similarity?
fuzzy-toolkit/string-similarity: same compareTwoStrings and findBestMatch, same results, 2 to 4 times faster.
fuzzy-toolkit or Fuse.js? fuzzy-toolkit finds more results with typos and is faster with a reusable index, and it also grades answers, dedupes, joins lists and finds names in a text. Scores go from 0 to 100, higher is closer.
Does it work with AI assistants?
Yes. npx fuzzy-toolkit mcp gives agents the tools, and npx fuzzy-toolkit ai-setup teaches your project's assistants the API.
Contributing
Bug reports with a wrong score, new languages, presets and feature ideas are very welcome. To write a language pack or a preset, npx fuzzy-toolkit new-pack language pt starts the package, and the Wanted list shows what people asked for. Otherwise open an issue or a discussion. See CONTRIBUTING.md to get started.
Everyone who contributed is on the Contributors page.
If fuzzy-toolkit saves you time, you can support it on Ko-fi or leave a star.
License
MIT
fuzzy-toolkitnpm install fuzzy-toolkit