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

Diagram Sync

Last updated:

Diagram Sync automatically exports your Mermaid diagrams to SVG and or PNG images whenever you save or close a Mermaid file (.mmd). This enables you to effortlessly keep your documentation images up-to-date without manual export steps.

When you save or close a Mermaid file, Diagram Sync:

  1. Checks if the file matches any of your configured patterns
  2. Renders the diagram using Mermaid Studio’s Mermaid diagram export service
  3. Saves the output as SVG and/or PNG in the same directory as the source file with an appended extension.

For example, saving docs/architecture.mmd creates docs/architecture.mmd.svg alongside it.

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

    Diagram Sync settings

  2. Check Export on save.

    Enable Diagram Sync

  3. Click the + button to add a sync rule.

  4. Enter a pattern to match your diagram files and select output formats (SVG, PNG, or both).

    Add sync pattern

  5. Click Apply.

Each rule specifies which files to export and in what format:

ColumnDescription
EnabledToggle this rule on/off
PatternGlob pattern matching file paths
SVGExport to SVG format
PNGExport to PNG format
PatternWhat It Matches
**/*.mmdAll .mmd files anywhere in the project
**/*.mermaidAll .mermaid files anywhere in the project
docs/**/*.mmd.mmd files in the docs folder and subfolders
diagrams/*.mmd.mmd files directly in the diagrams folder

You can create multiple rules to handle different directories differently. If a file matches multiple rules that specify different output formats, artifacts from all matched rule formats are generated without generating any duplicate artifacts.

Absolute paths are treated as relative to the project root. Diagram Sync cannot be enabled for arbitrary files outside the project.

When you have a Mermaid file open, a sync status icon appears in the bottom-right status bar.

Status bar widget

The following badge colors indicate the current sync status:

BadgeStatusMeaning
GreenSyncedExports are up-to-date
YellowOut of SyncSource changed since last export
RedErrorExport failed
NoneNo rules match this file

When a file is syncing, an animated spinner is shown in place of the sync icon.

Hover over the icon to see the current status, file name, and last synced timestamp.

Click the icon to open a popup with status details, links to generated files, and a Sync Now button.

Sync popup

To force an immediate export:

  1. Click the status bar widget.

  2. Click Sync Now.

This triggers an export outside the normal save-based workflow.

Artifacts are saved in the same directory as your source file with an appended extension:

Source FileSVG ArtifactPNG Artifact
flow.mmdflow.mmd.svgflow.mmd.png
docs/arch.mermaiddocs/arch.mermaid.svgdocs/arch.mermaid.png

If a diagram has syntax errors, Diagram Sync:

  • Displays a red error icon in the status bar widget
  • Logs the error details to the IDE log
  • Preserves your existing artifacts (doesn’t delete or corrupt them)

Fix the syntax error and save again to retry the export.

Settings are stored per-project in .idea/mermaidstudio/sync.xml. You can share settings with your team by committing this file to version control.