Skip to content

janus fmt — Code Formatter

Canonical formatter. One style. No arguments. No configuration files. Run janus fmt and your code looks like every other Janus file on the planet.

Terminal window
# Format a file in-place
janus fmt src/main.jan
# Check if a file is formatted (CI mode)
janus fmt --check src/main.jan

--check exits with code 1 if the file isn’t formatted, and prints a line-by-line diff showing exactly what would change:

src/main.jan: not formatted
Diff in src/main.jan:
1 - func add( a:i64,b:i64 )->i64 do
1 + func add(a: i64, b: i64) -> i64 do
2 - return a+b
2 + return a + b

No murder mysteries. The body is right there.

The formatter enforces the structural divide — the only non-negotiable rule in Janus syntax:

ContextDelimiter
func, if, else, while, for, using, nurserydo..end
match, enum, struct, flags, literals{ }

If you write func main() { }, the formatter rewrites it to func main() do ... end. This is the single structural correction.

4 spaces per nesting level. No tabs. No trailing whitespace.

func process(data: i64) -> i64 do
if data > 0 do
return transform(data)
end
return 0
end

Spaces around binary operators, after commas, after colons in type annotations:

// Before
let x=a+b*c
func add(a:i64,b:i64)->i64 do return a+b end
// After
let x = a + b * c
func add(a: i64, b: i64) -> i64 do return a + b end

One blank line between top-level declarations. No double blanks. No blank lines at block boundaries.

All comments are preserved. Doc comments (///) stay above their declaration. Line comments (//) stay at end-of-line or on their own line. The formatter never removes your comments.

janus fmt(janus fmt(source)) == janus fmt(source) — always. Format it twice, get the same result. Every test in the formatter’s 34-test suite verifies this property.

The full formatting rules are documented in SPEC-FMT in the Janus repository at docs/SPEC-FMT.md.

  • No configuration. No .janusfmt.toml. One style for the entire ecosystem.
  • No partial formatting. Format the whole file or nothing.
  • No “minimal diff” mode. The formatter produces canonical output every time.

“A language without fmt tolerates arguments about whitespace. Janus doesn’t.”