Flow Mermaid - VS Code Extension

Transform your code into interactive Mermaid flow diagrams.
A Visual Studio Code extension that sends selected code (or an entire file) to an AI-powered API and renders the resulting Mermaid diagram in an interactive panel, with click-to-source navigation, in-place editing, and export options.
Features
- AI-powered conversion: select code, JSON, or any structured text and convert it into a Mermaid diagram
- Interactive webview: theme-integrated panel with zoom, pan, and fullscreen
- Click-to-source: click a node to jump to the matching line in your code
- Right-click node menu: copy a node's label, copy its matching source line, or regenerate the diagram without that step
- Editable diagram source: edit the generated Mermaid syntax directly and re-render without calling the API again
- Regenerate with instructions: ask for a refinement (for example "simplify" or "add error branches") and get an updated diagram
- Diagram history: step back and forward through diagrams generated in the same panel
- Search nodes: find and highlight a node by label
- Insert into document: insert the current diagram as a fenced Mermaid code block into the file you're editing
- Export options: copy Mermaid code, export SVG, export PNG, or copy the PNG directly to the clipboard
- CodeLens: a "Visualize" action above every function and method
- Diagram Entire File: generate a diagram from the whole active file, not just a selection
- Response caching: re-running on an unchanged selection skips the network call
- Configurable backend: point the extension at your own API endpoint
How to Use
Requirements
- VS Code 1.104.0 or higher
- An internet connection (both the diagram API and the Mermaid rendering library are loaded over the network)
Generate a diagram
There are four ways to start:
- Select code, then right-click - highlight any code, JSON, or text in the editor, right-click, and choose Flow Mind.
- Select code, then use the keybinding - press
Ctrl+Alt+M (Cmd+Alt+M on macOS).
- Select code, then use the Command Palette - press
Ctrl+Shift+P (Cmd+Shift+P on macOS), type Flow Mind, and press Enter.
- Use CodeLens - click the "Visualize" link that appears above any function or method; no selection needed.
To diagram an entire file instead of a selection, open the Command Palette and run Flow Mind: Diagram Entire File.
A progress notification appears while the diagram is generated (you can cancel it), then a panel opens beside your editor with the rendered diagram. Running the command again reuses the same panel instead of opening a new one.
Work with the diagram panel
The toolbar along the top of the panel has these actions, in order:
| Button |
Action |
| Copy |
Copy the raw Mermaid syntax to the clipboard |
| Export SVG |
Download the diagram as an SVG file |
| Export PNG |
Download the diagram as a PNG file |
| Copy PNG to Clipboard |
Copy the diagram image directly to the clipboard |
| Edit Mermaid Code |
Open a panel to edit the Mermaid syntax directly (see below) |
| Search Nodes |
Find and highlight a node by label |
| Regenerate with Instructions |
Prompt for refinement instructions and ask the API for an updated diagram |
| Insert into Document |
Insert the diagram as a fenced Mermaid block into the file you were last editing |
| Previous / Next Diagram |
Step back and forward through this panel's diagram history |
| Toggle Theme |
Switch the diagram between light and dark rendering |
| Zoom Out / Zoom In |
Adjust zoom from 25% to 300% in 15% steps |
| Reset Zoom |
Return to 100% |
| Fit to Screen |
Scale the diagram to fit the visible area |
| Toggle Fullscreen |
Expand the diagram to fill the window |
Navigate from the diagram back to your code
- Click a node to jump to the matching line in the source file. If the match is uncertain, a short list of candidate lines is shown to choose from.
- Right-click a node for more options:
- Copy label copies the node's text.
- Copy source line copies the matching line of source code without navigating to it.
- Regenerate without this step asks the API to redraw the diagram excluding that node.
Edit the diagram source directly
Click Edit Mermaid Code to open a text panel containing the current Mermaid syntax. Make changes and either click Apply or press Ctrl+Enter (Cmd+Enter on macOS) to re-render. Click the reset button to restore the originally generated code. Edits stay local to the panel - they are not sent back to the API and are not added to the diagram history.
Zoom, pan, and fullscreen
| Action |
How |
| Zoom in / out |
+ / -, or Ctrl + scroll wheel over the diagram |
| Reset zoom |
0 |
| Fit to screen |
Fit to Screen button |
| Pan |
Scroll without Ctrl, drag with the mouse, or arrow keys (hold Shift to pan further per press) |
| Enter fullscreen |
Toggle Fullscreen button |
| Exit fullscreen |
Double-click the diagram, press Escape, or click the fullscreen button again |
These shortcuts are active while the diagram panel has focus, and are suspended while typing in the edit or search box so normal typing is not intercepted.
Configuration
The extension sends the code you select to an API endpoint, which returns Mermaid syntax. By default this is a hosted endpoint operated by the developer; nothing you select is stored or logged by the extension itself.
To point the extension at your own backend, or otherwise adjust its behavior, open Settings (Ctrl+,) and search for "Flow Mind", or edit settings.json directly:
| Setting |
Default |
Description |
flowMermaid.apiEndpoint |
hosted endpoint |
Where selected code is sent |
flowMermaid.apiKey |
(empty) |
Sent as an Authorization: Bearer <token> header if set |
flowMermaid.diagramType |
auto |
Diagram type hint sent to the API (flowchart, sequence, class, state, er); the effect depends on the backend supporting it |
flowMermaid.requestTimeout |
30000 |
Request timeout in milliseconds |
flowMermaid.showCodeLens |
true |
Show the "Visualize" CodeLens above functions |
A custom backend should accept POST { "code": "<selected text>" } (plus diagramType and/or instructions when set) and respond with { "mermaid": "<mermaid syntax>" } (or diagram/code, or plain Mermaid text).
Troubleshooting
"Select some code first"
No text was selected (or the file was empty) when the command ran. Highlight some code and try again, or use "Flow Mind: Diagram Entire File" to diagram the whole file instead.
Diagram not rendering
Open Developer Tools (Help > Toggle Developer Tools) and check the console for errors. Confirm you have an internet connection, since Mermaid is loaded from a CDN.
Request fails or times out
Check that the configured flowMermaid.apiEndpoint is reachable, and increase flowMermaid.requestTimeout if the backend is slow to respond.
Zoom shortcuts not working
Make sure the diagram panel has focus and your cursor is over the diagram when using Ctrl + scroll. Keyboard shortcuts are suspended while typing in the edit or search box.
Changelog
See CHANGELOG.md.
Acknowledgments
- Mermaid.js, for the diagram rendering library
- The VS Code extension API
Contact: tamil@tamix.in