4 ms·
Show HN: Mermaid Formatter – CLI and library to auto-format Mermaid diagrams
I built a zero-dependency formatter for Mermaid diagram syntax. It normalizes indentation, whitespace, and arrow spacing across all diagram types.
Features:
- CLI tool (mermaidfmt) with stdin/file/in-place support
- Programmatic API for integration (e.g. format Mermaid blocks in Markdown)
- Nested block indentation (alt/loop/par/subgraph track depth)
- Context-aware parsing (else only inside alt, and only inside par)
- Arrow normalization: A->>B:msg → A ->> B: msg
npm install -g mermaid-formatter