Documentation

Mermaid Diagrams in Markdown and Word Documents

Mermaid turns text definitions into diagrams that stay easy to update with the surrounding documentation. A clean source block and a readable layout are essential when the diagram will be embedded in DOCX.

Use a fenced Mermaid block

Label the code fence mermaid so the preview knows to render a diagram instead of a normal code sample. Start with a small graph, then add branches and labels incrementally.

```mermaid
flowchart LR
  Draft --> Review
  Review --> Export
```

Design for a document page

A wide diagram that works on a monitor may be unreadable on a portrait Word page. Prefer top-to-bottom direction for long processes, keep labels short, and split unrelated flows into separate diagrams.

  • Avoid tiny text produced by too many nodes.
  • Use one diagram for one question.
  • Check contrast in the exported image.
  • Add a text explanation for accessibility.

Troubleshoot before export

If the diagram does not render in preview, check the diagram type, indentation, brackets, and quoted labels. Export only after the visual appears correctly; raw Mermaid source in the DOCX is a sign that rendering failed.

Apply this guide

Related Markdown guides