Zero-dependency formatter for Mermaid diagram syntax. Current version 0.3.0, targets Node >=18. Provides CLI tool (mermaidfmt), Prettier plugin, and programmatic API. Supports all major diagram types (sequence, flowchart, class, state, ER, gantt, etc.) and formats Mermaid code blocks inside Markdown files. Differentiators: lightweight with zero runtime dependencies, uses its own AST parser, normalizes arrow message spacing (A->>B:msg → A ->> B: msg), and integrates with Prettier for consistent formatting across projects. Release cadence is irregular.
npm install mermaid-formatterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates how to use the programmatic API: formatting raw Mermaid source and Mermaid code blocks in Markdown.
Use 'mermaidfmt' command instead of 'mermaid-formatter'
Add '"plugins": ["mermaid-formatter/prettier-plugin"]' to .prettierrc
Assign the returned string directly: const result = formatMermaid(input);
Upgrade Node to version 18 or later
Ensure the input string contains a valid diagram declaration (e.g., 'sequenceDiagram')
Add a valid diagram declaration as the first line of the input, or use 'detectDiagramType' to verify
Ensure mermaid-formatter is installed locally: npm install --save-dev mermaid-formatter
Ensure mermaid-formatter is installed locally alongside prettier: npm install --save-dev prettier mermaid-formatter
No dependency data recorded yet.