Flowgraph Studio vs Mermaid CLI: Building diagram exports into CI

Compare Mermaid CLI with Flowgraph's render API and flowgraph-cli for automated SVG and PNG exports, checking diagrams in CI, and drawing diagrams from the code itself.

Comparisons · · Updated · 4 min read

Flowgraph Studio is our product. We've tried to describe the other tools fairly, from their own documentation as of November 2026.

The diagram looks right in the editor. Then the documentation build produces different spacing, a missing font, or an image that no longer matches the rest of the handbook.

Automating diagram exports is partly a rendering problem and partly an agreement about what the build must reproduce. Mermaid CLI and Flowgraph Studio both turn text into images. They suit different answers to that agreement.

A Mermaid definition and a theme feed a rendering step, which produces an SVG for documentation and a PNG for slides
An example build pipeline. Keep the source and the rendering settings with the generated images.

Start with what the build promises

Say a release pipeline publishes a service-flow diagram to the handbook as SVG and to a release presentation as PNG. Both should show the same relationships, in the team's colours.

The repository holds the Mermaid source, the rendering settings and the build steps. Images are outputs. A reviewer should be able to trace any image back to the commit that produced it.

flowchart TB
  src[service-flow.mmd] --> check{Valid Mermaid?}
  theme[theme.json] --> render
  check -->|yes| render[Render]
  check -->|no| fail[Fail the job, name the file and line]
  render --> svg[SVG for the handbook]
  render --> png[PNG for slides]

Reproducing an image takes more than a saved colour. The renderer version, the fonts and the output size all change the result. Decide whether a standard Mermaid render is enough, or whether the build must keep choices made in a particular editor.

Mermaid CLI: a strong local option

The official Mermaid CLI (mmdc) turns a Mermaid file into SVG, PNG or PDF. It can also go through a Markdown file, render each Mermaid block, and replace it with an image. It takes a theme, a background, custom CSS and icon packs, and it's published as a Docker image too. It's MIT-licensed. A basic conversion is one line:

mmdc -i service-flow.mmd -o service-flow.svg

For teams that are happy to maintain build tools, that's an attractive start. Pin the package or image version, keep the configuration in the repository, and render inside an environment you control.

The work is operational as well as editorial. The CLI renders through a headless browser, so the runner needs that browser and the fonts your diagrams use. Keep those choices explicit, so a new runner doesn't quietly produce a different image. For ordinary Mermaid styling, this may be all the infrastructure you need.

Flowgraph: the editor's look, from an API or a CLI

Flowgraph Studio's render API takes a Mermaid file and a theme exported from the editor and returns SVG or PNG. The output keeps what the editor adds: rich nodes with cloud icons, and positions set by hand in Manual mode. There's no browser to install on the runner; the rendering happens on Flowgraph's side.

flowgraph-cli wraps it for CI. It's MIT-licensed, has no dependencies and needs Node 20 or later:

npx flowgraph-cli check docs
npx flowgraph-cli render docs --out-dir build/diagrams --theme theme.json

check validates every .mmd file and every Mermaid block in Markdown under docs, and prints each failing file with the line of the error. render writes the images. The CI guide has a GitHub Actions workflow.

A hosted call adds an outside dependency, an API key and a monthly allowance: 50 renders on Free (with a small watermark), 5,000 on Pro and 20,000 on Pro Max. Failed renders aren't counted. Pull requests from forks may not get your secrets, so decide how those are checked.

From version 0.2.0, flowgraph-cli code also draws diagrams from the source code on the runner: a codebase map, module dependencies, a route map, class diagrams, call maps and function flowcharts, for TypeScript, JavaScript, Python, Java, Go and C#. It needs no key and sends nothing anywhere, and the same commit always gives the same Mermaid. Mermaid CLI renders diagrams you've written; this writes them from the code:

npx --yes flowgraph-cli@0.3.0 code deps --out docs/diagrams/dependencies.mmd
git diff --exit-code docs/diagrams

The second line fails the job when the committed diagram no longer matches the code.

Make a failed render visible

A documentation job should never publish an empty image, or keep a stale one while reporting success. Fail the job when rendering fails, and keep the error with the commit that caused it.

For a new pipeline, try three cases: a valid diagram, a deliberate syntax error, and a label long enough to strain the layout. The first tests the normal path. The second tests that failure reaches the build. The third tests whether a technically successful image is still readable.

You don't need a screenshot test for every arrow. A reviewed sample diagram, pinned versions and a visible failure path are a far better start.

Choose the dependencies you want to own

Mermaid CLI is a good fit when standard Mermaid output and a self-contained toolchain meet your needs, and when you'd rather not send diagrams to a service. Flowgraph is worth using when the output should keep its editor's themes, icons and layout, or when you want diagrams drawn from the code and checked in CI.

The question isn't whether a command or an HTTP request is easier to write. It's which rendering environment your team can run reliably, and whether it reproduces the diagram readers were promised.

Comparing hosted renderers instead? See Flowgraph Studio vs Kroki.

More from the blog

Follow the blog by RSS