Guide to validating Mermaid diagrams in markdown files using CLI tools, pre-commit hooks, and CI/CD pipelines.

Documents

DocumentDescription
Validation Tools & CLICLI tools and validators for Mermaid syntax checking
CI/CD & Pre-commit IntegrationSetting up validation in automated workflows

Overview

Mermaid diagrams embedded in markdown files can contain syntax errors that break rendering. Validation tools catch these errors during development, pre-commit, or CI/CD stages before they reach production.

Quick Start

Install Official Mermaid CLI

Terminal window
npm install -g @mermaid-js/mermaid-cli

Validate a Diagram

Terminal window
mmdc -i diagram.mmd -o /tmp/test.svg

Validate All Diagrams in Markdown

Terminal window
npm install -g mermaid-validate
mermaid-validate validate-md document.md