Harper: A Deterministic, Offline Grammar Checker
Better Stackgo watch the original →
the gist
Harper is a privacy-focused, rule-based grammar checker written in Rust that runs locally without cloud connectivity or machine learning, making it ideal for code comments and documentation.
Deterministic Grammar Checking
Harper functions as a rule-based engine rather than a generative AI model. It processes text by tagging words individually and running them through 287 handwritten Rust rules. Because the engine is deterministic, it provides consistent results for the same input every time, avoiding the erratic behavior often associated with machine learning models that may suggest contradictory changes. The engine is optimized for speed, with performance claims of under 10 milliseconds per check.
Implementation and Workflow Integration
Harper is designed to be embedded directly into developer toolchains rather than acting as a standalone monitoring application. It supports native integration via a Language Server Protocol (LSP) implementation, allowing it to function within editors like Neovim, Zed, Helix, and Emacs with minimal configuration. The tool is particularly effective for technical writing, as it can parse code files to check grammar within comments while ignoring actual code syntax. It also compiles to WebAssembly, enabling the full engine to run locally within a browser tab.
Limitations and Trade-offs
Users trade broad linguistic coverage for privacy and speed. Harper lacks the tone coaching, clarity suggestions, and full-sentence rewriting capabilities found in Grammarly. It is currently limited to English and five dialects. Because it relies on a finite set of rules, it may fail to flag complex grammatical errors that do not trigger a specific rule. Additionally, users may encounter false positives, such as the tool flagging proper nouns like "Cloudflare." While the tool is lightweight, some users have reported high memory usage, with the language server occasionally exceeding 1 GB of RAM.