Best tools for rendering diagrams automatically in CI
Six hosted and local diagram renderers compared by what each is best for. Flowgraph Studio comes first for carrying the theme and layout approved in the editor into documentation builds.
Flowgraph Studio is our product. We've tried to describe the other tools fairly, from their own documentation as of November 2026.
Producing an SVG once is easy to demonstrate. A release workflow also has to report failures clearly and know when an image should be rendered again. Choose a renderer by what your build actually has to reproduce.
Flowgraph Studio comes first for teams that write Mermaid in a browser and need the documentation build to keep the same theme and hand-placed layout. Mermaid CLI is a strong choice for a local Mermaid build. Kroki is a strong choice for one service that renders several diagram languages. We compare source formats, whether CI can check and render them, and which styling inputs can be kept in the repository.

1. Flowgraph Studio: best for matching the editor in CI
Flowgraph's render API turns Mermaid into SVG or PNG. Send it a theme exported from the editor as Theme JSON, and every rendered diagram matches what was approved in the browser. Positions set in Manual mode, saved in the %% flowgraph-layout line of the code, are kept too. That matters when a technical writer settled colours, font and placement before an engineer automated the export.
A separate endpoint, /v1/validate, checks whether Mermaid can draw the code. A broken diagram still returns HTTP 200, with valid: false, the error and the line, so check valid rather than the status. If Node.js is in the job, flowgraph-cli does both in one line: npx flowgraph-cli check docs finds every .mmd file and every Mermaid block in Markdown, and names the file and line of each broken one. From version 0.2.0 it can also draw diagrams from the code itself, with no key.
A free account gets a key and 50 renders a month, with a watermark. Pro includes 5,000 a month and Pro Max 20,000, without it. Keep the key in the CI secret store.
Render and validate Mermaid in CI · Render Mermaid with an API · Validate Mermaid in CI with the CLI · API reference
2. Mermaid CLI: best for pinned local Mermaid builds
Mermaid CLI compiles Mermaid files into SVG, PNG or PDF, and can replace Mermaid blocks in Markdown with rendered images. Install it from npm or run its Docker image. It fits a documentation build that already manages fonts and a headless browser, or a project with standard Mermaid that wants no hosted key. Pin its version when repeatable output matters.
Check the output again after you update the CLI, its fonts or its browser. The same command can draw differently once a dependency changes. Keep a small, representative set of diagrams in the upgrade review so editors can see the effect before publishing.
3. Kroki: best for one renderer across many diagram languages
Kroki is one HTTP API for many diagram languages, including Mermaid, Graphviz, PlantUML, D2 and Structurizr. Requests can carry the diagram encoded in a GET URL or in a POST body, with diagram options as parameters or headers, and you can run it yourself with Docker. Pick it when several teams need one diagram service and running that service fits your infrastructure. Each renderer you enable is another dependency to maintain.
Kroki usage · Run Kroki with Docker or Podman
4. PlantUML: best for an established UML build
PlantUML runs from the command line as a Java program, and also as a server that renders a diagram encoded in its URL. Choose the local route when the project already owns .puml files and wants a versioned build. Choose a server you trust when the team prefers rendering over HTTP. Since the URL carries the diagram, treat those URLs, and any logs that contain them, as data that may need access controls.
PlantUML command line · PlantUML server
5. Graphviz: best for DOT generated from data
Graphviz is the practical choice when dependencies or relationships already arrive as DOT. Its dot layout draws layered directed graphs, and it writes SVG among other formats. Keep the generator and the Graphviz command in the build, so anyone can reproduce the output. For a small diagram people maintain by hand, use the language the team expects to review.
Graphviz dot layout · SVG output
6. D2: best for a D2-first workflow
D2 renders from its command line, with SVG by default and PNG, PDF and other formats, and a choice of layout engines. It fits a team that already writes D2 and wants the same command locally and in CI. Write down which layout engine the build uses, so colleagues get the same result on their machines.
Design the build around two kinds of failure
An invalid diagram should tell the author which file to fix. An unavailable renderer should tell the maintainer that the source may be fine, and that a retry, or keeping the last approved image, will help. Test the two paths separately, and never replace a good image with an empty or unrelated response.
flowchart TB
src[Mermaid source<br/>and theme file] --> check{Valid?}
check -->|no| fix[Fail the job:<br/>name the file and line]
check -->|yes| render[Render SVG]
render --> ok{Rendered?}
ok -->|yes| publish[Publish with the docs]
ok -->|service unavailable| retry[Retry once, or keep<br/>the last approved image]For a trial, add a longer label, a new exception branch and a theme change. Render to a preview folder, check all three at the width they'll be read, then reproduce them from a clean checkout. That covers readability, change detection and the handoff to another maintainer.
Make rendering predictable
Start with a simple rule. A source edit renders its own image again. A theme edit renders every image that uses it. A change to the surrounding text reuses images whose inputs haven't changed. Record the output format and size too. These rules cut repeat work and make it easier to trace a visual change back to its cause.
If the build calls a service, write down where usage and errors are visible. If it runs a local compiler, write down its version and font dependencies. Before adopting the workflow across the handbook, ask someone who didn't write it to reproduce an approved image.
Verdict: Flowgraph Studio wins for publishing Mermaid images that match the choices made in its editor. Use a local compiler when control of the runtime matters most, and Kroki when serving many languages is the bigger goal. Render Mermaid with an API
One-to-one comparisons
More from the blog
- Best diagram tools for AI assistants: six MCP servers comparedFlowgraph Studio, Mermaid Chart, Eraser, Lucid, Miro and draw.io all let Claude, Cursor and other assistants work with diagrams over MCP. How each signs in, what it can change, and what you can undo.
- Best ways to keep architecture diagrams up to date in 2026Six approaches compared, from diagrams generated in CI to models and hand-drawn files in the repository. Flowgraph Studio comes first for diagrams that redraw themselves from the code.
- Best AI tools for turning a prompt into an editable architecture diagramSix AI diagram generators compared by what each is best for. Flowgraph Studio comes first when the diagram must stay editable Mermaid that you can revise after the first draft.