Diagrams are only rendered as images when Render as Image is enabled. You can control this globally via the Styles panel → Code Blocks setting, or override it per block with the
renderAsImage attribute directly on the code block.Basic syntax
Use a fenced code block with a supported diagram language:Supported diagram languages
| Language | Code identifier | Description |
|---|---|---|
| Mermaid | mermaid | Flowcharts, sequence diagrams, class diagrams, Gantt charts, and more |
| PlantUML | plantuml | UML diagrams (class, sequence, activity, use case, etc.) |
| GraphViz | graphviz or dot | Graph and network visualizations |
| Structurizr | structurizr | C4 architecture diagrams |
| BlockDiag | blockdiag | Simple block diagrams |
| SeqDiag | seqdiag | Sequence diagrams |
| ActDiag | actdiag | Activity diagrams with swimlanes |
| NwDiag | nwdiag | Network topology diagrams |
| PacketDiag | packetdiag | Packet/protocol header diagrams |
| C4 with PlantUML | c4plantuml | C4 architecture model using PlantUML syntax |
| DBML | dbml | Database markup language for ER diagrams |
| Ditaa | ditaa | ASCII art to diagram conversion |
| ERD | erd | Entity-relationship diagrams |
| TikZ | tikz | LaTeX-based technical drawings |
| UMlet | umlet | UML diagrams |
| Vega | vega | Declarative data visualizations |
| WireViz | wireviz | Wiring harness and cable documentation |
Mermaid examples
Flowchart
Sequence diagram
Class diagram
PlantUML example
GraphViz example
Captions and anchors
Addcaption and anchor attributes to include the diagram in the List of Figures and enable cross-references:
Alignment
Control horizontal alignment with thealign attribute:
Rendering as code (renderAsImage=false)
By default, diagram language code blocks are rendered as images. SetrenderAsImage=false to display the source code as a regular code block instead:
When
renderAsImage=false is set on a diagram code block, the block is treated as a regular code block. If it has a caption, it appears in the List of Code Listings instead of the List of Figures.Global default
You can set the default for all code blocks in your document’s style settings:- defaults → styles → code → renderAsImage:
true(default) orfalse
renderAsImage attribute always overrides the global default.
Attribute reference
| Attribute | Values | Description |
|---|---|---|
renderAsImage | true, false | Render as image (default: true for diagram languages) or show source code |
caption | String | Figure caption for auto-numbering in the List of Figures |
anchor | String | Anchor ID for cross-references |
align | left, center, right | Horizontal alignment |
width | Number (pixels) | Width of the rendered diagram image |
spacingBefore | Number (pt) | Spacing before the diagram |
spacingAfter | Number (pt) | Spacing after the diagram |
Diagrams are rendered server-side during document export. In the live editor preview, diagram code blocks are displayed as syntax-highlighted code.
