whatisgithub

What is mermaid-cli?

mermaid-js/mermaid-cli — explained in plain English

Analysis updated 2026-06-26

4,551JavaScriptAudience · developerComplexity · 2/5Setup · easy

In one sentence

A command-line tool that converts Mermaid diagram text files into PNG, SVG, or PDF images, well-suited for automating diagram generation in documentation and build pipelines.

Mindmap

mindmap
  root((repo))
    What it does
      Text to diagram image
      PNG SVG PDF output
    Install options
      npm global install
      Docker container
      Node.js API
    Use cases
      Docs automation
      CI pipeline diagrams
      Markdown processing
    Audience
      Developers
      Docs writers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Convert a Mermaid text file into a PNG or SVG image for use in documentation or presentations.

USE CASE 2

Process a Markdown file containing diagram code blocks and replace each one with an actual image reference.

USE CASE 3

Add automatic diagram generation to a CI pipeline or documentation build workflow.

USE CASE 4

Call the Node.js API to render Mermaid diagrams from inside another JavaScript program.

What is it built with?

JavaScriptNode.jsnpmDocker

How does it compare?

mermaid-js/mermaid-clicrabbly/print.jspatrickkunka/mixitup
Stars4,5514,5534,547
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasyeasyeasy
Complexity2/52/51/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Some Linux environments hit a browser sandboxing issue, a documented workaround is provided in the README.

So what is it?

Mermaid is a system where you write plain-text descriptions of diagrams, like flowcharts or sequence diagrams, and the tool draws the actual visual for you. This repository, mermaid-cli, is a command-line companion that converts those text description files into image files you can use elsewhere. You give it an input file containing your diagram text, and it produces a PNG, SVG, or PDF output file. A one-line command covers the basic case: point it at your input file, tell it where to write the output, and it handles the rest. You can also control the visual theme (for example, a dark background) and whether the background is transparent. If you have a Markdown document that contains diagram code blocks, you can run the whole file through the tool and it will replace each diagram block with an actual image reference. Installation options are flexible. The most common route is installing it globally through npm, the standard JavaScript package manager. A Docker container image is also available if you prefer not to install anything on your machine directly. There is also a Node.js API if you want to call it from inside another JavaScript program, though that API does not follow the same version stability guarantees as the command-line tool itself. The tool uses a browser engine in the background to render the diagrams, which is why some Linux environments run into a sandboxing issue during setup. The README links to a documented workaround for that. On most machines the setup is straightforward, and the tool is well-suited for automation pipelines where diagrams need to be generated as part of a build or documentation workflow.

Copy-paste prompts

Prompt 1
I have a Mermaid flowchart in a file called diagram.mmd. Give me the mermaid-cli command to convert it to a transparent-background PNG with a dark theme.
Prompt 2
I have a Markdown doc with several mermaid code blocks. Show me the mermaid-cli command to process the whole file and replace each block with an image reference.
Prompt 3
Write a GitHub Actions workflow step that uses mermaid-cli to auto-generate diagram images on every push.
Prompt 4
I'm running mermaid-cli on Ubuntu and getting a browser sandbox error. Walk me through the documented fix.

Frequently asked questions

What is mermaid-cli?

A command-line tool that converts Mermaid diagram text files into PNG, SVG, or PDF images, well-suited for automating diagram generation in documentation and build pipelines.

What language is mermaid-cli written in?

Mainly JavaScript. The stack also includes JavaScript, Node.js, npm.

How hard is mermaid-cli to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is mermaid-cli for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.