TOOL

dot2mermaid

dot2mermaid is a small command-line converter, written in Go by GitHub user r3code, that translates graphs expressed in the Graphviz DOT language (DOT) into Mermaid.js flowchart syntax (Mermaid). Its purpose is narrow and practical: many documentation systems, wikis, and Markdown renderers (GitHub, GitLab, Obsidian, and similar) natively render Mermaid but not the DOT dialect consumed by Graphviz, so existing DOT diagrams must be re-expressed in Mermaid to display inline. dot2mermaid automates that one-way rewrite. It is MIT-licensed and modest in scope, with a single main.go, a test file, and only a brief README; the codebase has seen limited development and low community uptake.

Unlike naive text-substitution scripts, dot2mermaid parses its input with the gographviz library, calling Parse and Analyse to build a structured in-memory graph before emitting output. This gives it a real understanding of the DOT model rather than line-by-line pattern matching. From the analysed graph it walks the node set and edge set, reading each node's shape and label attributes and each edge's optional label, then delegates Mermaid generation to an internal flowchart package that assembles the final text. Input arrives either from a named file argument or from standard input via a flag, making the tool composable in shell pipelines.

The conversion is deliberately shape-aware but coarse. DOT shapes are mapped onto the nearest Mermaid node shape: cylinder to Mermaid's database/cylinder node, rectangle to a rectangular node, octagon approximated as a hexagon, rarrow handled only loosely, and unspecified shapes falling back to a stadium (rounded) node. Label text is unquoted and its escaped quotes normalized before being placed into the Mermaid node or edge.

The limitations are significant and honest to note. There is no handling of DOT subgraphs or clusters, so nested grouping is flattened or lost; attribute coverage is confined to shape and label, meaning colors, styles, ranks, ports, and edge styling are discarded; and the target is specifically the Mermaid flowchart type, not class, state, or entity diagrams. It is best viewed as a lightweight, best-effort porting aid for simple directed graphs rather than a faithful round-trip translator.

Within the broader conversion landscape it sits alongside other DOT-to-Mermaid utilities such as convert2mermaid, pu2mm, the browser-based Graphviz-to-Mermaid, and the reverse-direction mermaid2dot. For richer multi-format graph interchange beyond this single pairing, general converters like GraphInOut cover far more formats.

Input Formats

Output Formats

Frequently Asked Questions

What graph file formats does dot2mermaid support?

See the list on this page — it shows every format dot2mermaid can read, write and display.

How do I import a graph into dot2mermaid?

Convert your file to a format dot2mermaid can read, then open it in dot2mermaid. Use GraphInOut to get a dot2mermaid-compatible file in seconds.

How do I convert a file so dot2mermaid can open it?

Use the convert links above — upload or paste your graph, pick a format dot2mermaid accepts and download the result, right in your browser.