Canolean

A canonical source formatter for Lean 4, written in Rust with no external dependencies and verified with Aeneas against Canolean/CanonicalLeanSource.lean.

Getting started View on GitHub


Given the same imports and syntax, two files with the same tokens and comments always format to the exact same output, regardless of how they were originally laid out.

Canolean only formats syntax it can handle safely. If a file uses unsupported syntax, it fails with an error instead of guessing.

Canolean is experimental (0.x). While formatting is canonical within a release, the canonical format itself may still change before 1.0, and across future major releases.

Quick start

Requires Rust 1.88+ and Lean 4.36.0.

cargo install --offline --path .
canolean --check --bundled-only path/to/lean
canolean --in-place --bundled-only path/to/lean

See Getting started for build and usage details.