mmdc
Mermaid CLI for generating diagrams from text
TLDR
SYNOPSIS
mmdc [options]
DESCRIPTION
mmdc is the CLI for the Mermaid diagramming library. It renders diagrams defined in Mermaid's text-based syntax into SVG, PNG, or PDF output using a headless Chromium browser via Puppeteer.Supported diagram types include flowcharts, sequence diagrams, class diagrams, state diagrams, Gantt charts, pie charts, ER diagrams, and more. When given a Markdown file as input, mmdc extracts and renders embedded Mermaid code blocks, replacing them with generated images.The --configFile option accepts a JSON file that configures Mermaid behavior and is merged with the --theme option, with the config file taking precedence.
PARAMETERS
-i, --input FILE
Input file path. Use `-` for stdin. Files ending in .md or .markdown are treated as Markdown.-o, --output FILE
Output file path. Use `-` for stdout. Defaults to `{input}.svg`.-e, --outputFormat FORMAT
Output format: svg, png, or pdf. Inferred from output extension by default.-t, --theme THEME
Mermaid theme: default, dark, forest, or neutral.-b, --backgroundColor COLOR
Background color for PNG/SVG output (default: white).-w, --width WIDTH
Page width in pixels (default: 800).-H, --height HEIGHT
Page height in pixels (default: 600).-s, --scale FACTOR
Puppeteer scale factor for deviceScaleFactor (default: 1).-f, --pdfFit
Scale PDF output to fit chart dimensions.-c, --configFile FILE
JSON configuration file for Mermaid settings.-C, --cssFile FILE
Path to custom CSS file for injection into the page.-I, --svgId ID
ID attribute for the SVG element (default: my-svg).-p, --puppeteerConfigFile FILE
JSON configuration file for Puppeteer launch options.-a, --artefacts PATH
Output path for images when processing Markdown files.-q, --quiet
Suppress log output to stdout.-V, --version
Display version number.-h, --help
Display help information.
CAVEATS
Requires Node.js and downloads a Chromium browser via Puppeteer for rendering. The first run may take time due to the browser download. The scale factor (-s) only affects PNG output resolution.
HISTORY
mmdc is the CLI for Mermaid, a JavaScript-based diagramming and charting tool created by Knut Sveidqvist. The CLI package is published as @mermaid-js/mermaid-cli on npm.
