Skip to main content
The MermaidConfig interface defines all configuration options available for Mermaid diagrams. This includes global settings, theme configuration, security options, and diagram-specific configurations.

Properties

'default' | 'base' | 'dark' | 'forest' | 'neutral' | 'null'
The CSS style sheet theme for the diagram. You may also use themeCSS to override this value.
any
Variables to customize the selected theme.
string
Custom CSS to override theme styles.
'classic' | 'handDrawn'
Defines which main look to use for the diagram.
number
default:0
Seed for the handDrawn look. Important for automated tests as they will always find differences without the seed. Default value of 0 gives a random seed.
string
Defines which layout algorithm to use for rendering the diagram.
number
The maximum allowed size of the user’s text diagram.
number
Defines the maximum number of edges that can be drawn in a graph.
object
Configuration options for the ELK layout algorithm.
boolean
Enable dark mode styling.
boolean
Whether to use HTML tags for rendering labels on nodes and edges. Diagram-specific htmlLabels settings are deprecated; use this root-level setting instead.
string
Specifies the font to be used in the rendered diagrams. Can be any possible CSS font-family.
string
Alternative font family.
'trace' | 0 | 'debug' | 1 | 'info' | 2 | 'warn' | 3 | 'error' | 4 | 'fatal' | 5
The amount of logging to be used by Mermaid.
'strict' | 'loose' | 'antiscript' | 'sandbox'
Level of trust for parsed diagram.
  • strict: Only safe elements and attributes are allowed
  • loose: All elements and attributes are allowed
  • antiscript: Scripts are not allowed
  • sandbox: Sandboxed rendering
boolean
Dictates whether Mermaid starts on page load.
boolean
Controls whether arrow markers in HTML code are absolute paths or anchors. This matters if you are using base tag settings.
string[]
Specifies which currentConfig keys are considered secure and can only be changed via call to mermaid.initialize. This prevents malicious graph directives from overriding a site’s default security.
boolean
Specifies if Mermaid can expect the dependent to include KaTeX stylesheets for browsers without their own MathML implementation. If disabled and MathML is not supported, math equations are replaced with a warning. If enabled and MathML is not supported, Mermaid falls back to legacy rendering for KaTeX.
boolean
Forces Mermaid to rely on KaTeX’s own stylesheet for rendering MathML. Due to differences between OS fonts and browser’s MathML implementation, this option is recommended if consistent rendering is important. If set to true, ignores legacyMathML.
boolean
default:false
Controls if the generated IDs of nodes in the SVG are generated randomly or based on a seed. If set to false, the IDs are generated based on the current date and thus are not deterministic. This matters if your files are checked into source control (e.g., git) and should not change unless content is changed.
string
Optional seed for deterministic IDs. If set to undefined but deterministicIds is true, a simple number iterator is used. You can set this attribute to base the seed on a static string.
DOMPurifyConfiguration
Configuration options to pass to the dompurify library.
boolean
Enable text wrapping.
number
Default font size for diagrams.
boolean
Enable automatic wrapping for markdown content.
boolean
Suppresses inserting ‘Syntax error’ diagram in the DOM. This is useful when you want to control how to handle syntax errors in your application.

Diagram-specific configurations

FlowchartDiagramConfig
Configuration specific to flowchart diagrams.
SequenceDiagramConfig
Configuration specific to sequence diagrams.
GanttDiagramConfig
Configuration specific to Gantt diagrams.
JourneyDiagramConfig
Configuration specific to journey diagrams.
TimelineDiagramConfig
Configuration specific to timeline diagrams.
ClassDiagramConfig
Configuration specific to class diagrams.
StateDiagramConfig
Configuration specific to state diagrams.
ErDiagramConfig
Configuration specific to entity relationship diagrams.
PieDiagramConfig
Configuration specific to pie diagrams.
QuadrantChartConfig
Configuration specific to quadrant chart diagrams.
XYChartConfig
Configuration specific to XY chart diagrams.
RequirementDiagramConfig
Configuration specific to requirement diagrams.
ArchitectureDiagramConfig
Configuration specific to architecture diagrams.
MindmapDiagramConfig
Configuration specific to mindmap diagrams.
IshikawaDiagramConfig
Configuration specific to Ishikawa diagrams.
KanbanDiagramConfig
Configuration specific to Kanban diagrams.
GitGraphDiagramConfig
Configuration specific to Git graph diagrams.
C4DiagramConfig
Configuration specific to C4 diagrams.
SankeyDiagramConfig
Configuration specific to Sankey diagrams.
PacketDiagramConfig
Configuration specific to packet diagrams.
BlockDiagramConfig
Configuration specific to block diagrams.
RadarDiagramConfig
Configuration specific to radar diagrams.
VennDiagramConfig
Configuration specific to Venn diagrams.

Example usage

TypeScript definition