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 getTehUser is flagged correctly.
  • File type filtering — built-in awareness of dozens of file types; individual types can be excluded or configured separately.
  • JSON output--format json produces machine-readable results for integration with custom tooling or editors.
  • Diff mode--diff shows 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 servertypos-lsp provides 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.typos

Usage

Checking for typos

# Check the current directory (prints typos but does not fix)
typos

# Check a specific file or directory
typos src/
typos README.md

Fixing 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 --diff

Machine-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-changes

Inspecting 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 --identifiers

Configuration

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 = false

CI 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: typos

typos vs codespell

Featuretyposcodespell
LanguageRustPython
False positive strategyKnown-misspelling listDictionary + ignore list
Auto-fix
Identifier splitting
JSON output
LSP server
GitHub Action
Pre-commit hook