ledgerfmt

ledgerfmt

A deterministic formatter for plain-text accounting files.

ledgerfmt reads journal files, normalises spacing, aligns amount columns and rewrites them in a stable canonical form. Running it twice produces identical output, which makes it safe to wire into a pre-commit hook or a CI check.

Why

Plain-text ledgers are edited by hand, so they drift: tabs mix with spaces, amounts drift out of alignment, accounts get inconsistent capitalisation. Diffs then contain more whitespace noise than actual bookkeeping changes.

ledgerfmt fixes the formatting and nothing else. It never invents transactions, never reorders entries and never touches amounts — a reformat is always a no-op for your balances.

Install

cargo install ledgerfmt

Prebuilt binaries for Linux, macOS and Windows are attached to each release.

At a glance

$ ledgerfmt --check accounts.journal
accounts.journal: 3 entries would be reformatted

$ ledgerfmt --write accounts.journal
accounts.journal: formatted
ledgerfmt targets the common subset of the ledger and hledger journal syntaxes. Directives it does not recognise are preserved verbatim.