typos
A source code spell checker that finds and fixes spelling mistakes with low false positives, fast enough for monorepos.
typos is a source code spell checker designed to run unattended in CI
pipelines and pre-commit hooks. Unlike general-purpose spell checkers that flag
anything outside a known dictionary, typos works from a curated list of common
misspellings and their corrections. This approach keeps false positives low
enough that the tool can safely auto-fix without requiring human review of every
suggestion.
Features
- Low false positive rate — uses a list of known misspellings rather than a full dictionary, so it rarely flags intentional abbreviations, acronyms, or domain-specific identifiers.
- Auto-fix — rewrites files in place with
--write-changes; only reports ambiguous cases where multiple corrections are possible. - Fast — designed to run on large monorepos without adding noticeable CI overhead.
- Identifier-aware — splits camelCase, snake_case, and similar identifier
formats before checking, so
getTehUseris flagged correctly. - File type filtering — built-in awareness of dozens of file types; individual types can be excluded or configured separately.
- JSON output —
--format jsonproduces machine-readable results for integration with custom tooling or editors. - Diff mode —
--diffshows what would change without modifying files. - GitHub Actions integration — published as an Action for zero-config CI use.
- pre-commit hook — available as a pre-commit hook for local enforcement.
- LSP server —
typos-lspprovides editor integration via the Language Server Protocol.
Installation
cargo install typos-cli --locked# Debian / Ubuntu
# Not in the default apt repositories; use cargo or a release binary from
# https://github.com/crate-ci/typos/releases
# Fedora
# Not in the default dnf repositories; use cargo or a release binary.
# macOS
brew install typos-cli
# Arch Linux
pacman -S typos
# Nix
nix-env -iA nixpkgs.typosUsage
Checking for typos
# Check the current directory (prints typos but does not fix)
typos
# Check a specific file or directory
typos src/
typos README.mdFixing typos
# Automatically rewrite all unambiguous corrections
typos --write-changes
# Short form
typos -w
Ambiguous cases (where more than one correction is plausible) are reported but never auto-fixed, requiring a manual decision.
Viewing what would change
# Show a unified diff without modifying files
typos --diffMachine-readable output
# Emit one JSON object per line; exit code 2 means typos were found
typos --format json
# Read from stdin, write corrected version to stdout
typos - --write-changesInspecting effective configuration
# Dump the resolved configuration to stdout
typos --dump-config -
# List all files that would be checked
typos --files
# List all identifiers that would be checked
typos --identifiersConfiguration
typos looks for a _typos.toml (or typos.toml, or a [typos] table in
Cargo.toml) in the project root.
[default.extend-words]
# Treat "teh" as correct — e.g. a contributor's surname
teh = "teh"
[default.extend-identifiers]
# Suppress a known false positive in a legacy identifier
AttributeIDSupressMenu = "AttributeIDSupressMenu"
[default]
extend-ignore-identifiers-re = [
# Ignore identifiers that match a regex pattern
"AttributeID.*Supress.*",
]
[files]
# Exclude generated or localised files from checking
extend-exclude = ["localized/*.po", "vendor/"]
[type.po]
extend-glob = ["*.po"]
# Check filenames but not file contents for .po files
check-file = falseCI integration
GitHub Actions
- uses: crate-ci/typos@master
This runs typos over the whole repository on every pull request with no additional configuration needed.
pre-commit
# .pre-commit-config.yaml
repos:
- repo: https://github.com/crate-ci/typos
rev: v1.44.0
hooks:
- id: typostypos vs codespell
| Feature | typos | codespell |
|---|---|---|
| Language | Rust | Python |
| False positive strategy | Known-misspelling list | Dictionary + ignore list |
| Auto-fix | ✅ | ✅ |
| Identifier splitting | ✅ | ❌ |
| JSON output | ✅ | ❌ |
| LSP server | ✅ | ❌ |
| GitHub Action | ✅ | ✅ |
| Pre-commit hook | ✅ | ✅ |