# Main Libraries Used by Automattic/harper: A Complete Dependency Breakdown

> Explore the core libraries powering Automattic/harper. Discover its Rust and JavaScript/TypeScript dependencies for high-performance language analysis and cross-platform front-ends.

- Repository: [Automattic/harper](https://github.com/Automattic/harper)
- Tags: api-reference
- Published: 2026-08-01

---

**Harper relies on a dual-stack architecture: Rust crates for high-performance language analysis and JavaScript/TypeScript libraries for cross-platform front-ends.**

Harper is an open-source, grammar-aware spell checker developed by Automattic. Understanding the main libraries used by Automattic/harper reveals how the project balances computational efficiency with broad platform support. This guide examines the critical dependencies powering both the core engine and its surrounding ecosystem.

## Rust Core Engine Dependencies (`harper-core`)

The heart of Harper lives in [`harper-core/Cargo.toml`](https://github.com/Automattic/harper/blob/main/harper-core/Cargo.toml). These **Rust crates** handle tokenization, spell-checking, grammar rules, and serialization.

### Text Processing & Tokenization

- **pulldown-cmark** – Markdown parser that extracts plain text for linting. Essential for checking documentation and readme files.
- **unicode-blocks / unicode-script / unicode-width** – Unicode utilities for character category detection, script identification, and display width calculation.
- **regex** – Pattern-matching engine for rule-based grammar checks.

### Spell-Checking & Dictionary Storage

- **fst** – Finite State Transducer implementation powering compressed, fast-lookup dictionaries.
- **levenshtein_automata** – Fuzzy matching for typo detection and suggestion generation.
- **trie-rs** – Trie structure for efficient dictionary prefix searches.
- **zip** – Compressed dictionary file handling.

### Performance Optimizations

- **hashbrown** – Serde-enabled hash map with superior performance over standard library alternatives.
- **smallvec** – Stack-allocated vectors for token storage, reducing heap allocations.
- **foldhash** – Fast hasher for internal hash tables.
- **cached / lru** – Memoization and least-recently-used caching for expensive dictionary operations.
- **boxcar** *(optional, `concurrent` feature)* – Parallel execution support for multi-threaded linting.

### Serialization & Developer Experience

- **serde / serde_json** – Configuration and result serialization.
- **thiserror** – Ergonomic error type definitions.
- **strum / strum_macros** – Enum display and iteration utilities.
- **paste** – Macro concatenation for generated code.
- **bitflags** – Compact rule configuration storage.

### Additional Core Utilities

- **blanket** – Fast text span indexing.
- **itertools** – Extended iterator adapters.
- **ordered-float** – Total ordering for floating-point confidence scores.
- **ammonia** – HTML sanitization for rendered markdown messages.

### Internal Sub-Crates

- **harper-brill** – Brill-style part-of-speech tagger.
- **harper-thesaurus** *(optional)* – Synonym lookup for enriched suggestions.

## JavaScript/TypeScript Front-End Libraries

Harper exposes its engine to multiple platforms through carefully selected **JavaScript dependencies**.

### harper.js (NPM Wrapper)

Located at [`packages/harper.js/package.json`](https://github.com/Automattic/harper/blob/main/packages/harper.js/package.json):

- **fflate** – Fast gzip/Zlib decompression for loading the `harper-wasm` binary in browsers.

### harper-web (SvelteKit Site)

Located at [`packages/web/package.json`](https://github.com/Automattic/harper/blob/main/packages/web/package.json):

- **svelte / vite** – UI framework and build tooling
- **tailwindcss** – Utility-first styling
- **drizzle-orm** – Type-safe database operations
- **lodash-es** – Modular utility functions
- **chart.js** – Data visualization
- **reveal.js** – Presentation slides
- **svelte-ace** – Code editor integration

### VS Code Extension

Located at [`packages/vscode-plugin/package.json`](https://github.com/Automattic/harper/blob/main/packages/vscode-plugin/package.json):

- **vscode** – Extension API
- **harper-ls** – Language server integration
- **harper-js** – Browser-compatible linting fallback

### Harper Desktop

Located at [`harper-desktop/package.json`](https://github.com/Automattic/harper/blob/main/harper-desktop/package.json):

- **tauri** – Rust-based native app framework
- **svelte / vite** – Shared UI stack with the web platform

## Supporting Infrastructure Crates

| Crate | Purpose | Entry Point |
|-------|---------|-------------|
| **harper-ls** | LSP implementation for editor integration | [`harper-ls/Cargo.toml`](https://github.com/Automattic/harper/blob/main/harper-ls/Cargo.toml) |
| **harper-wasm** | WebAssembly build for browser deployment | [`harper-wasm/Cargo.toml`](https://github.com/Automattic/harper/blob/main/harper-wasm/Cargo.toml) |
| **harper-brill** | POS tagging sub-crate | [`harper-brill/Cargo.toml`](https://github.com/Automattic/harper/blob/main/harper-brill/Cargo.toml) |
| **harper-thesaurus** | Thesaurus lookup sub-crate | [`harper-thesaurus/Cargo.toml`](https://github.com/Automattic/harper/blob/main/harper-thesaurus/Cargo.toml) |

## Key Source Files for Library Research

Understanding the main libraries used by Automattic/harper starts with these entry points:

- [`harper-core/Cargo.toml`](https://github.com/Automattic/harper/blob/main/harper-core/Cargo.toml) – Primary Rust dependency manifest
- [`harper-core/src/lib.rs`](https://github.com/Automattic/harper/blob/main/harper-core/src/lib.rs) – Core engine orchestration
- [`packages/harper.js/package.json`](https://github.com/Automattic/harper/blob/main/packages/harper.js/package.json) – Minimal JS wrapper dependencies
- [`packages/web/package.json`](https://github.com/Automattic/harper/blob/main/packages/web/package.json) – Full front-end stack inventory
- [`harper-ls/Cargo.toml`](https://github.com/Automattic/harper/blob/main/harper-ls/Cargo.toml) – LSP server dependencies
- [`harper-wasm/Cargo.toml`](https://github.com/Automattic/harper/blob/main/harper-wasm/Cargo.toml) – WebAssembly build configuration

## Summary

- **Rust core** uses approximately 25 specialized crates spanning text processing (`pulldown-cmark`), spell-checking (`fst`, `levenshtein_automata`), performance (`hashbrown`, `smallvec`, `cached`), and serialization (`serde`).
- **JavaScript layer** minimizes runtime dependencies: `fflate` for decompression in [`harper.js`](https://github.com/Automattic/harper/blob/main/harper.js), full SvelteKit + Tauri stacks for UI applications.
- **Architecture pattern** – Heavy computation in Rust, platform exposure through WebAssembly and native bindings, with thin TypeScript wrappers for integration.

## Frequently Asked Questions

### What is the most critical Rust crate for Harper's spell-checking?

**fst** provides the finite state transducer that powers Harper's compressed dictionary lookups. Combined with **levenshtein_automata** for fuzzy matching and **trie-rs** for prefix searches, these three crates form the backbone of typo detection and correction suggestions.

### Why does Harper use both hashbrown and foldhash?

**hashbrown** serves as the primary high-performance hash map with Serde support for configuration data, while **foldhash** provides an optimized hasher specifically for internal hash tables where serialization isn't required. This dual approach maximizes speed while maintaining flexibility.

### How does Harper run in browsers without a Rust runtime?

The **harper-wasm** crate compiles the core engine to WebAssembly, which [`harper.js`](https://github.com/Automattic/harper/blob/main/harper.js) loads and decompresses using **fflate**. This allows the full Rust engine to execute in any JavaScript environment without native binary dependencies.

### What makes Harper different from other spell-checkers architecturally?

Harper's **polyglot design** separates concerns: Rust handles all linguistic analysis with memory-safe, parallelized code, while multiple JavaScript front-ends (VS Code extension, web UI, desktop app) share the same compiled engine through WebAssembly or LSP protocols.