Skip to main content

Turn Mermaid code blocks into diagrams in Confluence

See the Mermaid code blocks on a Confluence page or blog post drawn as diagrams, and turn the ones you choose into Mermaid Diagram macros.

Before you begin​

  • To see the diagrams: permission to view the page.
  • To turn code blocks into macros: permission to edit the page, and an active Mermaid Diagrams license.
  • Publish or discard any unpublished changes to the page first. The app won't change a page with unpublished changes.

Turn code blocks into macros​

  1. Open the page and select β€’β€’β€’ (More actions) > Apps > Mermaid diagrams on this page.

    The page's More actions menu with Apps open, showing Mermaid diagrams on this page

    A dialog shows each Mermaid code block on the page, drawn as a diagram, with the heading it's under.

  2. Check the diagrams. On each one you can select Show source, Copy source, Download as PNG or SVG, or View fullscreen.

  3. Select the code blocks to turn into macros, or select Select all to convert.

    The Mermaid diagrams on this page dialog with two code blocks drawn as diagrams and both selected

  4. Select Convert, for example Convert 2 diagrams.

Result: The page is saved once, as a new version under your name. Each selected code block is now a Mermaid Diagram macro.

The result screen: 2 diagrams converted, saved as version 2, with Undo and Close and reload page

Select Close and reload page to see the diagrams. To put the code blocks back, select Undo. Undo works until someone else publishes the page. After that, restore the previous version from the page history.

Good to know​

  • A code block with an error converts too, so you can fix it in the diagram editor.
  • A ```mermaid fence typed as plain text, not in a code block, is drawn but stays as it is.
  • If you can only view the page, the dialog shows the diagrams without the convert options.
  • On a page without Mermaid code blocks, people who can edit it can select Insert an example diagram to add a macro at the end of the page.

If the page wasn't changed​

The dialog says why, and nothing on the page changes:

MessageWhat to do
This page has unpublished changesPublish or discard the changes in the page editor, then try again
The page changed while you were reviewingSomeone published a new version. Select Review again
This space needs approval before publishingConvert the code blocks in the page editor instead, by adding macros by hand
You can't edit this pageAsk the page owner for edit permission
The page wasn't changedUsually a short network problem. Select Try again. Your selection is kept