The Role of Hunspell in Chromium's Offline Spellchecker

This article explores how the open-source Hunspell library powers the offline, multi-language spellchecking system inside the Chromium web browser. It covers why Chromium integrates Hunspell, how the library handles complex rules across different languages, the use of optimized binary dictionaries to save system memory, and how this local architecture protects user privacy.

What is Hunspell?

Hunspell is an open-source spellchecker and morphological analyzer originally designed for the Hungarian language, which is known for its complex grammar and word structures. Because of its ability to handle intricate language rules, it has become the industry standard for open-source software. Chromium embeds the C++ Hunspell library directly into its codebase to serve as the default engine for local, offline spellchecking on Windows, Linux, and ChromeOS (while macOS and Android typically rely on their native operating system spellcheckers).

Managing Multiple Languages Through Morphology

A basic spellchecker compares a typed word against a massive list of known words. However, this approach fails in languages with rich morphology and word compounding, such as German, Turkish, or Finnish, where words are constantly combined or modified with prefixes and suffixes.

Hunspell solves this by using two components for every language:

  • A Dictionary File (.dic): Contains only the root words of a language.
  • An Affix File (.aff): Contains the grammatical rules for how prefixes, suffixes, and compound words can be legally attached to those root words.

By combining root words with affix rules on the fly, Hunspell allows Chromium to recognize millions of valid word variations across dozens of languages without needing to store every single word variation on the user's hard drive.

Chromium’s BDIC Optimization

While standard Hunspell dictionaries are efficient, loading large text files into a web browser can still slow down performance and consume excessive RAM. To keep the browser fast, Chromium modifies how Hunspell reads data.

Chromium compiles the standard Hunspell .dic and .aff files into a single, custom binary format called .bdic (Binary Dictionary). When you select a language in your browser settings, Chromium downloads the specific .bdic file for that language.

This binary format is memory-mapped, meaning Chromium does not have to load the entire dictionary into the system's RAM. Instead, the browser reads the file directly from the disk as needed. Furthermore, because Chromium uses a multi-process architecture, memory-mapping allows multiple open tabs to share the exact same Hunspell dictionary data simultaneously without duplicating memory usage.

Real-Time Processing and Privacy

When you type into a text box on a webpage, Chromium’s renderer process isolates each word and passes it to the embedded Hunspell engine. Hunspell checks the word against the local .bdic file and the user's custom dictionary (words the user has manually added).

If Hunspell flags a word as incorrect, it triggers the browser to draw the familiar red squiggly line underneath the text. When the user right-clicks the misspelled word, Hunspell uses two algorithms to generate the replacement suggestions seen in the context menu:

  • N-gram similarity: Finds words that share similar letter sequences, fixing common typos and transposed letters.
  • Phonetic algorithms: Finds words that sound similar to the misspelled word, helping users who spell words the way they sound.

Because Hunspell runs entirely within the local Chromium client using downloaded .bdic files, the entire spellchecking process works completely offline. This architecture ensures that sensitive information, such as passwords, private messages, and financial data typed into web forms, is spellchecked securely on the device without ever being sent to an external server.