A lightweight full-text search library for the browser. Prefix, fuzzy, boosting, filters, suggestions, everything client-side and fast.
Search through MiniSearch docs in real time.
Add, replace and remove documents on the fly — see results update immediately.
Required fields: title (string), text (string), category (string). title (string), text (string). Optional: tags (string[]). IDs will be assigned automatically. tags (string[]), category (string).
remove: deletes immediately from the index.
discard: marks as deleted; vacuum cleans later.
Save and restore the index without reindexing (sync or async).
Save the current index + options and restore them after refreshing the page.
Compare results for standard indexing vs n-grams.
Snippets and docs links for all playground options.
import MiniSearch from 'minisearch';
const miniSearch = new MiniSearch({
fields: ['title', 'text'],
storeFields: ['title', 'category']
});miniSearch.addAll([
{ id: 1, title: 'Angular', text: 'Frontend framework', category: 'frontend' },
{ id: 2, title: 'React', text: 'UI library', category: 'frontend' },
{ id: 3, title: 'Node.js', text: 'JS runtime', category: 'backend' },
]);const results = miniSearch.search('angular');
// => [{ id: 1, score: 1.38, match: { angular: ['title'] } }]// Tolerates typos (up to 20% of term length)
const results = miniSearch.search('anglar', { fuzzy: 0.2 });// Prefix matching: match words starting with 'ang'
const results = miniSearch.search('ang', { prefix: true });const results = miniSearch.search('framework', {
boost: { title: 2 } // title matches are 2x more important
});const results = miniSearch.search('search', {
filter: (result) => result.category === 'frontend'
});const suggestions = miniSearch.autoSuggest('ang', { prefix: true });
// => [{ suggestion: 'angular', score: 5.2 }, ...]// Save
const json = JSON.stringify(miniSearch);
// Restore
const restored = MiniSearch.loadJSON(json, {
fields: ['title', 'text']
});| Feature | MiniSearch | Lunr.js | Fuse.js | FlexSearch |
|---|---|---|---|---|
| Size (gzip) | ~7 kB | ~8 kB | ~5 kB | ~6 kB |
| Fuzzy | Yes | Yes | Yes (core) | Yes |
| Prefix | Yes | Yes | No | Yes |
| Incremental indexing | Yes | No (rebuild) | N/A | Yes |
| Suggestions | Built-in | No | No | No |
| TF-IDF / scoring | Yes | Yes | No (Bitap) | No |
| TypeScript | Native | Yes | Yes | Partial |
Documentation search in the browser (online or offline).
Real-time suggestions (autoSuggest).
Filter results without a backend.
Works without network (built-in dataset).
Fast UX/search experiments without infrastructure.
Product search with ranking and filters.
MiniSearch is small but flexible. You can adapt it to your own data and UI.
Render matches as HTML (e.g. <mark>) and control what goes into [innerHTML].
Store URLs in documents and link to the original page directly from results.
Collect search timings and render an SVG sparkline to see how options affect latency.
A tiny yet powerful client-side full-text search library that brings instant, offline-capable search to any JavaScript application — no server required.
MiniSearch is a lightweight search engine written in JavaScript that performs full-text search entirely in the browser. Created by Luca Ongaro and available as an open-source project on GitHub (lucaong/minisearch), it weighs in at approximately 7 kB gzipped and carries zero external dependencies — making it one of the most efficient client-side search solutions available today. Unlike traditional search architectures that require a backend server, an Elasticsearch cluster, or a third-party API, MiniSearch indexes and queries your data directly on the user's device. This fundamental design choice means that search results appear instantaneously, with no network latency, no API rate limits, and no infrastructure costs. Whether you are building a documentation site, a product catalog, a note-taking application, or any content-rich interface, MiniSearch gives your users the kind of responsive, type-ahead search experience they expect from modern applications. It works seamlessly in all major browsers, in Node.js environments, and inside Web Workers, and it ships with full TypeScript support so you get reliable autocompletion and type safety right out of the box. For teams and solo developers alike, MiniSearch strikes a rare balance: it is simple enough to integrate in a single afternoon, yet powerful enough to handle thousands of documents with sub-millisecond query times.
MiniSearch packs an impressive set of search capabilities into its minimal footprint. At its core, it provides full-text search with relevance ranking powered by industry-standard TF-IDF and BM25 scoring algorithms — the same family of algorithms that power major search engines. Fuzzy search allows users to find results even when they misspell words, with configurable edit-distance thresholds that let you control how tolerant matching should be. Prefix search enables real-time type-ahead behavior, returning results as the user types each character, which is essential for building responsive autocomplete experiences. Field boosting lets you assign different weights to different parts of your documents — for example, making matches in a title count more heavily than matches in a description. You can filter results by any document attribute, combining full-text relevance with structured criteria like category, date range, or status. The built-in autoSuggest function provides ranked search term suggestions, perfect for dropdown autocomplete interfaces. MiniSearch also supports n-gram tokenization for languages and use cases where word boundaries are not straightforward, and it exposes hooks for custom tokenizers and term processing functions, so you can tailor every step of the indexing and search pipeline to your exact requirements. Incremental indexing means you can add, remove, or replace documents in the index at any time without rebuilding it from scratch.
Under the hood, MiniSearch builds an inverted index — the same data structure used by large-scale search engines — but optimized for in-memory operation within a browser search context. When you add documents to a MiniSearch instance, each document's specified fields are tokenized (split into individual terms), optionally processed through custom functions such as lowercasing or stemming, and then stored in a compact radix tree structure. This structure enables extremely fast prefix lookups and keeps memory consumption low even with large collections. When a user issues a query, MiniSearch tokenizes the search string using the same pipeline, looks up each term in the inverted index, and scores every matching document using configurable relevance algorithms. The scoring combines term frequency (how often a term appears in a document), inverse document frequency (how rare the term is across all documents), and optional field boost weights to produce a final relevance score. Results are returned as a sorted array ranked by relevance. One of MiniSearch's most practical features is its ability to serialize the entire index to a JSON snapshot and restore it later without needing to re-index the original documents. This means you can build the index at build time, during server-side rendering, or in a background process, save it as a JSON file, and load it instantly on the client — dramatically reducing initial page load times for applications with large datasets. The snapshot mechanism also makes MiniSearch ideal for offline search scenarios, since the serialized index can be cached in localStorage, IndexedDB, or a Service Worker cache.
MiniSearch excels in any scenario where you want to provide fast, relevant search without depending on a server. Documentation websites and knowledge bases are one of the most common use cases: projects like VitePress and other static site generators use client-side search to let visitors find information instantly across hundreds or thousands of pages, all without a backend API. E-commerce product catalogs benefit from MiniSearch's field boosting and filtering capabilities — users can search by product name while filtering by category and price range, with results ranked by relevance rather than simple string matching. Note-taking and personal knowledge management applications use MiniSearch to provide offline search across a user's entire library, which is critical for Progressive Web Apps (PWAs) that must function without network connectivity. Content management dashboards employ it to provide instant search over lists of articles, media assets, or user records, reducing perceived latency to zero. Blog platforms and portfolio sites integrate MiniSearch to offer visitors a search-as-you-type experience that feels native and immediate. Developer tools and API reference sites use the autoSuggest feature to build autocomplete dropdowns that guide users toward the right endpoint or function name. Even browser extensions and Electron desktop applications leverage MiniSearch because it runs entirely in JavaScript with no native dependencies, making it trivially portable across platforms. Any application that already has its data available on the client — whether loaded via an API, bundled at build time, or synced from a local database — can add high-quality search with just a few lines of code.
MiniSearch is engineered for performance at every level. Its approximately 7 kB gzipped bundle size means it adds virtually nothing to your application's download budget — smaller than most UI icons. The zero-dependency design ensures there are no transitive packages to audit, no version conflicts to resolve, and no unexpected bloat. In benchmarks, MiniSearch consistently indexes thousands of documents in tens of milliseconds and returns query results in under a millisecond, making it suitable for real-time search-as-you-type interfaces where every keystroke triggers a new query. Memory usage scales linearly and predictably with the number of indexed documents and the total volume of text, and the internal radix tree structure shares common prefixes across terms to minimize overhead. The library supports both BM25 and classic TF-IDF scoring, giving you control over relevance tuning. Custom tokenizers and processTerm functions let you integrate language-specific stemmers, stop-word lists, transliteration logic, or any other text normalization step your application requires. The extractField option allows you to index nested or computed properties without restructuring your data. TypeScript definitions are included in the package, providing full type safety, IntelliSense support, and compile-time error checking. MiniSearch works in any modern JavaScript runtime: browsers (including mobile Safari and Chrome on Android), Node.js for server-side pre-indexing, Deno, and Web Workers for offloading indexing to a background thread. The JSON serialization and deserialization API is deterministic and stable across versions, meaning you can pre-build indexes during your CI/CD pipeline and ship them alongside your static assets for instant load times.
Adding MiniSearch to your project takes just minutes. Install it via npm with 'npm install minisearch' or include it directly from a CDN. Create a new instance by specifying which fields to index and which fields to store for retrieval. Call the addAll method with an array of your documents — each document needs a unique ID and the text fields you want to make searchable. From that point on, calling the search method with any query string returns a ranked array of results. To enable fuzzy search, pass a fuzzy option with a numeric threshold (for example, 0.2 allows roughly one typo per five characters). For prefix search and autocomplete behavior, set the prefix option to true so that partial terms match the beginning of indexed words. The autoSuggest method returns ranked term suggestions rather than document results, which is ideal for building search dropdown interfaces. You can combine full-text queries with filters by passing a filter function that receives each document's stored fields and returns true or false. To persist and restore the index, use MiniSearch.loadJSON with a previously serialized snapshot — this is especially valuable for offline search in PWAs or for pre-built indexes in static sites. The MiniSearch Playground on this page lets you experiment with all of these features interactively: try different queries, toggle fuzzy and prefix matching, adjust boost weights, and see how results change in real time. For complete API documentation, examples, and advanced configuration guides, visit the official repository at github.com/lucaong/minisearch.
MiniSearch proves that powerful, relevant full-text search does not require a server — just a few kilobytes of JavaScript and the conviction that great search belongs everywhere, even offline.