Installation
Mermaid can be installed and used in multiple ways depending on your project setup. Choose the method that best fits your needs.Package managers
Install Mermaid as a dependency in your project using your preferred package manager:The current stable version of Mermaid is 11.12.2. The package includes TypeScript definitions out of the box.
CDN
For quick prototyping or simple projects, you can load Mermaid directly from a CDN without any installation:jsDelivr (Recommended)
unpkg
Module formats
Mermaid is distributed as an ES module. When you install the package, you get:- ES Module:
mermaid.core.mjs(main entry point) - TypeScript types:
mermaid.d.ts
Using with ES modules
Package exports
The package provides the following exports:Verify installation
After installation, you can verify that Mermaid is properly installed by importing it in your JavaScript file:Requirements
Mermaid is designed to work in modern JavaScript environments:- Browser support: Modern browsers with ES module support
- Node.js: For server-side rendering or build tools
- TypeScript: Full type definitions included
Dependencies
Mermaid relies on several powerful libraries:- D3.js - For graphical layout and drawing
- dagre-d3-es - For directed graph layouts
- cytoscape - For advanced graph layouts
- DOMPurify - For sanitizing user input
- KaTeX - For mathematical notation rendering
All dependencies are bundled with Mermaid, so you don’t need to install them separately.
Next steps
Now that you have Mermaid installed, let’s create your first diagram:Quickstart
Follow our quickstart guide to render your first diagram in minutes