Convert Graphviz DOT diagrams to Mermaid flowcharts for README files, Markdown documentation, design notes, and CI-generated docs.
npm install dot2mermaidFor local development in this repository:
npm install
npm testConvert a DOT file and print Mermaid to stdout:
npx dot2mermaid ./examples/simple.dotWrite the Mermaid output to a file:
npx dot2mermaid ./examples/simple.dot -o flowchart.mmdChoose a Mermaid flowchart direction:
npx dot2mermaid ./examples/subgraphs.dot --direction LRWhen working from a clone of this repository, the same CLI is available through npm scripts:
npm run convert -- ./examples/simple.dot
npm run convert -- ./examples/simple.dot -o flowchart.mmd
npm run convert -- ./examples/subgraphs.dot --direction LRimport { convert } from 'dot2mermaid';
const mermaid = convert(dotSource, { direction: 'TB' });DOT input:
digraph G {
Start -> Build
Build -> Test [label="Unit tests"]
Test -> Deploy
}Mermaid output:
flowchart TB
Start["Start"]-->Build["Build"]
Build["Build"]-->Test["Unit tests"]
Test["Test"]-->Deploy["Deploy"]
Files:
DOT input:
digraph Release {
subgraph cluster_prepare {
Plan -> Build
Build -> Test [label=CI]
}
subgraph cluster_publish {
Package -> Publish
}
Test -> Package
}Mermaid output with --direction LR:
flowchart LR
Test["Test"]-->Package["Package"]
subgraph cluster_prepare
Plan["Plan"]-->Build["Build"]
Build["Build"]-->Test["CI"]
end
subgraph cluster_publish
Package["Package"]-->Publish["Publish"]
end
Files:
See docs/conversion-rules.md for the supported DOT features, output shape, and current limitations.
Important behavior:
digraphedges using->become Mermaid-->edges.- The default Mermaid direction is
TB. - Use
--direction TB|LR|RL|BTto set the generated flowchart direction. - Node labels are used as Mermaid node text when available.
- DOT subgraphs are emitted as Mermaid
subgraph ... endblocks. - Mermaid does not show a parent graph label for an unlabeled subgraph. Add a DOT
labelwhen that text must appear in rendered documentation.
Mermaid has a default maxTextSize limit of 50,000 characters. Large DOT files may render with Maximum text size in diagram exceeded. Adjust the Mermaid configuration in the renderer when needed.
dot2mermaid is released under the MIT license.