Skip to content
Limited Time 40% off for early adopters — Get discount →

Mermaid Runtime

Last updated:

Mermaid Studio lets you customize how diagrams are rendered through runtime configuration overrides. You can set global defaults or configure different settings for preview, markdown, and export contexts.

Mermaid Studio supports four configuration contexts:

ContextDescription
BaseCommon configuration applied to all contexts
PreviewConfiguration for standalone .mmd file preview
MarkdownConfiguration for Mermaid diagrams in Markdown preview
ExportConfiguration for SVG/PNG export and printing

When rendering a diagram, configuration is shallow-merged in the following order:

Each layer overrides values from the previous layer. For example, if Base sets theme: dark and the Preview context sets theme: forest, previews will use the forest theme while other contexts use dark.

  1. Open Settings ( Command + Comma Control + Alt + S ) and navigate to Tools > Mermaid Studio > Mermaid Runtime.

    Mermaid Runtime Settings

  2. Click Edit… next to the context you want to configure.

  3. Edit the YAML configuration in the editor that opens.

    Config Editor with code completion

    The editor provides JSON schema-based validation and code completion for all available Mermaid configuration options. See the Mermaid configuration docs for the complete list of options.

  4. Save or close the file to apply changes.

To reset a context to defaults, click Reset next to that context.

Reset configuration

Set the diagram theme:

theme: dark

Available themes: default, dark, forest, neutral, base

Choose between classic and hand-drawn styles:

look: handDrawn

Available looks: classic, handDrawn

Specify the layout algorithm:

layout: elk

Available layouts depend on enabled layout plugins. See Layout Plugins below.

Customize the font used in diagrams:

fontFamily: "Fira Code, monospace"

You can configure options for specific diagram types using nested keys:

flowchart:
curve: basis
padding: 20
sequence:
mirrorActors: false
messageAlign: center

Each diagram type has its own set of configurable options. The editor provides code completion for all available options.

Mermaid Studio includes optional layout plugins that provide advanced layout algorithms.

ELK (Eclipse Layout Kernel) provides advanced layout algorithms for flowcharts, including layered, force-directed, and tree layouts.

To enable:

  1. Check ELK layout engine in the Mermaid Runtime settings
  2. Use layout: elk in your diagram’s frontmatter
---
config:
layout: elk
---
flowchart TD
A --> B --> C

Tidy-tree provides optimized tree layout algorithms for hierarchical diagrams. Currently supported only in mindmap diagrams.

To enable:

  1. Check Tidy-tree layout engine in the Mermaid Runtime settings
  2. Use layout: tidy-tree in your diagram’s frontmatter

Layout plugins may increase preview loading time and memory usage.

You can also configure individual diagrams using YAML frontmatter:

---
config:
theme: forest
flowchart:
curve: cardinal
---
flowchart LR
A --> B --> C

Per-diagram configuration takes precedence over runtime configuration overrides.

Example configuration

Configure the Export context to always use dark theme:

theme: dark

Configure the Preview context for a sketch-like appearance:

look: handDrawn
handDrawnSeed: 42

Setting handDrawnSeed ensures consistent rendering across previews.

Configure Base context with custom flowchart settings:

flowchart:
curve: basis
nodeSpacing: 50
rankSpacing: 75