MiniSearch
Tiny, dependency-free in-memory full-text search engine for browser and Node
Repository Health
Technical Analysis
MiniSearch is a lightweight, in-memory full-text search engine for JavaScript and TypeScript that runs comfortably in both Node and the browser, including memory-constrained mobile browsers. It supports exact match, prefix search, fuzzy matching, field boosting, and auto-suggestion, making it a popular choice for client-side “search as you type” experiences that need to work offline without a server round-trip.
With zero external runtime dependencies and a compact, well-tested codebase built around an efficient SearchableMap trie-like index, MiniSearch trades the scale of a hosted search service for speed, offline capability, and simplicity — documents can be added or removed from the index at any time, and the whole index can be serialized to JSON for persistence or transfer.
What You Get
- The
MiniSearchclass for building, updating, and querying an in-memory full-text index - Exact match, prefix search, and fuzzy (edit-distance-based) matching, each independently configurable
- Field boosting and per-term/per-document custom boost functions for tuning result ranking
- An auto-suggestion engine (
autoSuggest) for query auto-completion - JSON serialization/deserialization of the whole index via
toJSON/loadJSONfor persistence or transfer between processes
Common Use Cases
- Real-time ‘search as you type’ in web and mobile apps, keeping the index client-side to avoid server round-trips
- Offline-capable search in Progressive Web Apps or Electron apps where no search backend is available
- Adding full-text search to static sites (docs, blogs) by shipping a prebuilt JSON index to the browser
- Auto-complete/auto-suggest features that need typo tolerance and field-weighted ranking without a hosted search service
Under The Hood
Architecture MiniSearch centers on a single ~2,300-line MiniSearch class (src/MiniSearch.ts) composed with a custom SearchableMap (src/SearchableMap/SearchableMap.ts), a radix-tree-like structure optimized for prefix and fuzzy lookups over string keys. Documents are tokenized per configured fields, terms are inserted into the SearchableMap alongside per-document term frequency data, and search queries combine exact/prefix/fuzzy matching strategies (each independently weighted) with a TF-IDF-style scoring and boosting pipeline (field boost, term boost, document boost) before results are ranked and returned. The whole index can be serialized to and rehydrated from JSON via toJSON/loadJSON, letting a prebuilt index be shipped to a browser instead of built client-side.
Tech Stack Written entirely in TypeScript with zero runtime dependencies, bundled via Rollup into ESM, CommonJS, and UMD builds (dist/es, dist/cjs, dist/umd) so it can be dropped into either bundler-based projects or loaded directly via unpkg/jsdelivr in a browser. Types are hand-authored and exported from dist/es/index.d.ts, and API docs are generated with TypeDoc (typedoc.json).
Code Quality The project has an 80KB Jest-style test file (src/MiniSearch.test.js) alongside dedicated tests for SearchableMap, and CI badges show coverage tracking via Coveralls — indicating a genuinely well-tested core rather than a thin smoke-test suite. The single large MiniSearch.ts file is dense but consistently documented with JSDoc comments on nearly every public option and method, which keeps the surface navigable despite its size.
API Design The public API centers on one class with a small number of well-named methods (add, addAll, remove, search, autoSuggest) and richly typed options objects (SearchOptions, Options) that let simple use cases work with defaults while exposing deep customization (custom tokenizers, term processors, per-term/per-document boost functions) for advanced needs — a classic ‘simple things simple, complex things possible’ design that keeps the getting-started boilerplate to a single new MiniSearch({ fields: [...] }) call.
Used by 14 apps in this directory
medusa
Ecommerce
The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.
overleaf
Collaboration · Productivity
Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.
PostHog
Ab Testing Experimentation · Analytics · Developer Tools
The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.
Puter
Developer Tools · File Storage
A self-hostable, web-based internet OS with desktop GUI, cloud storage, AI drivers, and a developer SDK — all running in your browser.
Stormkit
Devops · Hosting Control Panel
Self-hostable platform for deploying and hosting modern web apps with automated CI/CD, custom domains, and a built-in serverless runtime — a true open-source alternative to Vercel and Netlify.