Hunspell Tutorial

By Xah Lee. Date:

This page shows you the basics of using hunspell.

Hunspell is a mature and modern spell checker, better than aspell. It is used by Apple, Google, Opera, Firefox,

The info on this page is tested with hunspell version 1.2.8.

Hunspell home page is at . Basic history at Wikipedia Hunspell .

# short usage summary
hunspell -h

How to check words interactively?

“cd” to the hunspell dir, then do:

hunspell -d en_US

that will start the program in a interactive shell. Type word and press enter to spell check it. To exit, press Ctrl+c.

Setting Environment Variables Path

If you have problem starting hunspell, you might need to set up some Environment Variables. [see Windows Environment Variable Tutorial] Here's some example on Windows using cmd.exe:

Windows with cmd.exe

Here is a example for adding hunspell executable to environment variable PATH in Windows Vista using cmd.exe:

setx PATH "C:\Program Files (x86)\ErgoEmacs 1.8.1\hunspell\;%PATH%"

You also need to set its dictionary file path. Like this:

setx DICPATH "C:\Program Files (x86)\ErgoEmacs 1.8.1\hunspell"

Note: hunspell 1.2.8 Windows port has a bug. The DICTIONARY and or DICPATH paths must be set in the Windows Registry. It won't work if these are set as session variables.

Once you have set these env vars, you can just type “hunspell” in any dir in the command line.

Unix with Bash

On unix bash, do it like this:

export PATH=/usr/local/bin:$PATH
export DICPATH=/usr/lib/firefox/dictionaries

Simple Usage

How to spell check a file interactively?

hunspell -d en_US filename.txt

It launches into a interactive command line interface.

How to spell check a file in batch?

cat myFile.txt | hunspell
hunspell -l myFile.txt

The output is long list with annoying “*” for each line. To not show those “*”, do this:

cat myFile.txt | hunspell -i utf-8 | grep -v \* | uniq

To list only the misspelled words, do:

cat myFile.txt | hunspell -l -i utf-8

How to specify the file's encoding?

Use the “-i” option, like this:

cat myFile.txt | hunspell -l -i utf-8

How to check a single word?

echo badword | hunspell

echo somee words ar good some badd | hunspell

Where is personal dictionary at?

It's at ~/.hunspell_default.