Back to guides
GuideChecked November 20266 min read

Mermaid diagrams in Ferrite

Mermaid diagrams in Ferrite: fence a block, open the viewer, and draw offline without a browser.

This is the how-to for diagrams in Ferrite 0.3.1. The short version, aimed at the search for an offline diagram editor, is a Markdown editor with offline Mermaid.

Fence a block

Put the diagram in a fenced block tagged mermaid. A small flowchart:

flowchart LR
  A[Write] --> B[Preview]

The source stays in the Markdown file. Rendered mode and Split draw it. You do not install Node, and you do not open a browser. The FAQ lists Mermaid with the other pieces that work with no connection.

The 11 types

Name the diagram the way Mermaid does. Ferrite renders these:

  • Flowchart
  • Sequence
  • State
  • Class
  • ER
  • Pie
  • Git graph
  • Gantt
  • Mindmap
  • Timeline
  • Journey

v0.3.1 rewrote the git graph against Mermaid's grammar, including tags, branch types, cherry-picks, and left-to-right or top-to-bottom layout. Sequence diagrams can number their messages. The other types were already in the set.

Open the viewer

Click a rendered diagram, use its popup button, or Ctrl+click it. Ferrite opens a large native viewer with zoom and pan, and with Select and Hand modes. Fit-to-pane scales the diagram to the viewer. The viewer follows the app's dark mode, and you stay inside Ferrite.

autonumber

On a sequence diagram, autonumber numbers the message arrows. You can set a start and a step. autonumber off clears numbering from that point on. It is a line in the diagram source, not a separate export setting.

Position hints

After the automatic layout, a flowchart node can be placed with a comment:

%% @pos nodeId x y

nodeId is the node. x and y are the position. A bad id still draws the diagram and shows a warning, which is the recoverable-warning behavior in the v0.3.1 notes. Dragging a node and writing the position back into the file is not in this version. That is planned with the other v0.3.2 diagram work.

What you cannot export yet

Ferrite does not export a diagram as SVG or PNG in v0.3.1. The roadmap puts SVG and PNG export in v0.3.2. Themed HTML export of a note includes Mermaid as inline SVG. A standalone SVG or PNG file of the diagram is the missing piece.

Math is a separate gap. There is no LaTeX in this version.

Keyboard shortcuts for the rest of the editor, outside the diagram source, are on the shortcuts page. Installers are on download, and the feature list is on features.

Questions