cmakefmt is a fast, correct CMake formatter built in Rust.
It replaces the aging Python cmake-format tool with a single native
binary that is easy to install, fast enough for pre-commit and CI, and
capable enough for real project use.
| Repository | Description |
|---|---|
cmakefmt/cmakefmt |
Main formatter — CLI, LSP server, library |
cmakefmt/vscode-cmakefmt |
VS Code extension |
cmakefmt/cmakefmt-action |
GitHub Action |
cmakefmt/homebrew-cmakefmt |
Homebrew tap |
brew install cmakefmt/cmakefmt/cmakefmt # macOS
pip install cmakefmt # any platform with Python
cargo install cmakefmt-rust # any platform
conda install -c conda-forge cmakefmt # conda-forgeOr download a pre-built binary from GitHub Releases.
Also available on winget, the VS Code Marketplace, Open VSX Registry, and as a Docker image.
- Fast — 104× faster than
cmake-format(geo-mean across 11 real-world fixtures); fast enough for editor-on-save, pre-commit hooks, and CI - One binary — no Python environment to manage
- LSP server —
cmakefmt lspprovides format-on-save in any editor - Workflow-first —
--check,--diff,--staged,--changed, machine-readable reports, and config introspection - Custom command aware — project-specific macros and functions format sensibly
- Comments preserved — barrier regions, fence blocks, and pragma support
cmakefmt config init # generate a starter .cmakefmt.yaml
cmakefmt . # preview formatted output
cmakefmt --diff . # view a unified diff of what would change
cmakefmt --in-place . # apply formatting across the whole project
cmakefmt --staged --check # use in pre-commit hooks
cmakefmt --path-regex 'src/.*' . # format CMake files only under src/- Getting Started
- CLI Reference
- Config Reference
- Editor Integration
- Migration from
cmake-format - Performance
- Playground
Issues, bug reports, and pull requests are welcome in
cmakefmt/cmakefmt.