Skip to content
| Marketplace
Sign in
Visual Studio Code>Visualization>Mermaid in CommentsNew to Visual Studio Code? Get it now.
Mermaid in Comments

Mermaid in Comments

Riemac

|
1 install
| (0) | Free
Render Mermaid fences inline in Python docstrings and source comments.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Mermaid in Comments

Render Mermaid diagrams inside Python docstrings and source comments directly in the VS Code editor. Move the cursor into a diagram fence to edit its source. Click Open Mermaid Preview above the fence to view the diagram at full size beside the editor.

在 VS Code 源码编辑器里原位显示 Mermaid 图。光标进入围栏时恢复源码,移开后重新显示图。点击 Open Mermaid Preview 可在旁边查看原尺寸图。

Installation

Install the .vsix from GitHub Releases with Extensions → Install from VSIX…. The extension requires VS Code 1.102 or later.

Usage

Write a Mermaid fence inside a triple-quoted Python module, class or function docstring. The r and u string prefixes also work.

r"""Document the lookup flow.

```mermaid
sequenceDiagram
    Reader->>Index: Look up a key
    Index-->>Reader: Return the result
```
"""

The same fences work in Python # comments and JavaScript or TypeScript // and /* … */ comments. Put each fence delimiter on its own line within the comment.

Mermaid 12.4.0 renders static SVG locally, including built-in diagram types, front matter and ELK layout. External image and icon resources and click callbacks are outside the static preview.

Inline diagrams fit the lines occupied by their fences. Use docstringMermaid.maxWidth to set the maximum inline width, or turn off docstringMermaid.inline to use the side preview. VS Code briefly opens the renderer panel the first time a diagram is rendered in a window.

Build from source

Use Node.js 22.12 or later and run npm ci, npm test and npm run package. Bundled dependency notices are included in the VSIX.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft