Scroll to navigation



codespell - detect spelling mistakes in source code


codespell [OPTIONS] [file1 file2 ... fileN]


codespell is designed to find and fix common misspellings in text files. It is designed primarily for checking misspelled words in source code, but it can be used with other files as well.

usage: codespell [-h] [--version] [-d] [-c] [-w] [-D DICTIONARY]

[--builtin BUILTIN-LIST] [-I FILE] [-L WORDS] [-r REGEX] [-s] [-S SKIP] [-x FILE] [-i INTERACTIVE] [-q QUIET_LEVEL] [-e] [-f] [-H] [-A LINES] [-B LINES] [-C LINES] [files [files ...]]

positional arguments:

files or directories to check

optional arguments:

-h, --help
show this help message and exit
show program's version number and exit
-d, --disable-colors
disable colors, even when printing to terminal (always set for Windows)
-c, --enable-colors
enable colors, even when not printing to terminal
-w, --write-changes
write changes in place if possible
Custom dictionary file that contains spelling corrections. If this flag is not specified or equals "-" then the default dictionary is used. This option can be specified multiple times.
--builtin BUILTIN-LIST
Comma-separated list of builtin dictionaries to include (when "-D -" or no "-D" is passed). Current options are: 'clear' for unambiguous errors, 'rare' for rare but valid words, 'informal' for informal words, 'code' for words common to code and/or mathematics, 'names' for valid proper names that might be typos, 'en-GB_to_en-US' for corrections from en-GB to en-US. The default is "--builtin clear,rare".
-I FILE, --ignore-words FILE
File that contains words which will be ignored by codespell. File must contain 1 word per line. Words are case sensitive based on how they are written in the dictionary file
-L WORDS, --ignore-words-list WORDS
Comma separated list of words to be ignored by codespell. Words are case sensitive based on how they are written in the dictionary file
-r REGEX, --regex REGEX
Regular expression which is used to find words. By default any alphanumeric character, the underscore, the hyphen, and the apostrophe is used to build words. This option cannot be specified together with --writechanges.
-s, --summary
print summary of fixes
-S SKIP, --skip SKIP
Comma-separated list of files to skip. It accepts globs as well. E.g.: if you want codespell to skip .eps and .txt files, you'd give "*.eps,*.txt" to this option.
-x FILE, --exclude-file FILE
FILE with lines that should not be changed
Set interactive mode when writing changes. 0: no interactivity. 1: ask for confirmation. 2 ask user to choose one fix when more than one is available. 3: both 1 and 2
-q QUIET_LEVEL, --quiet-level QUIET_LEVEL
Bitmask that allows codespell to run quietly. 0: the default, in which all messages are printed. 1: disable warnings about wrong encoding. 2: disable warnings about binary file. 4: shut down warnings about automatic fixes that were disabled in dictionary. 8: don't print anything for non-automatic fixes. 16: don't print fixed files.
-e, --hard-encoding-detection
Use chardet to detect the encoding of each file. This can slow down codespell, but is more reliable in detecting encodings other than utf-8, iso8859-1, and ascii.
-f, --check-filenames
check file names as well
-H, --check-hidden
check hidden files (those starting with ".") as well
-A LINES, --after-context LINES
print LINES of trailing context
-B LINES, --before-context LINES
print LINES of leading context
-C LINES, --context LINES
print LINES of surrounding context


Lucas De Marchi <>

May 2020 codespell 1.17.1