Graphviz Viewer & DOT Viewer (Live Preview)

Graphviz Viewer & DOT Viewer (Live Preview), a VS Code extension by Zovo

Graphviz viewer and DOT viewer for .dot and .gv files and dot blocks in Markdown, with live preview, error lines, pan, zoom and SVG or PNG export. Offline.

Install in VS CodeOpen the Marketplace page

Free, MIT license. Needs VS Code 1.90.0 or newer. Extension ID zovo.zovo-graphviz-preview, version 0.1.4.

See your Graphviz graph beside the .dot file as you type, click a node to jump to its line, and export it to SVG or PNG, with no Graphviz install.

A .dot file of an order service on the left. On the right, the preview draws it with two clusters named Edge and Core services, in the editor's dark colors. The toolbar shows the engine picker, Find node, zoom at 79%, Fit, 1:1, SVG and PNG, and the status reads 9 nodes, 9 edges, dot, 10 ms

Real output from VS Code 1.142 on macOS. The file is architecture.dot from scripts/make-samples.js, opened from the installed .vsix and captured through the debug port.

Quick start

  1. Install Graphviz Preview & DOT Viewer.
  2. Open a .dot or .gv file and click the preview icon in the editor title, or press Cmd+K V (Ctrl+K V on Windows and Linux).

"Graphviz: Get Started" in the Command Palette opens a short tour.

Questions people ask

Is Graphviz Viewer & DOT Viewer (Live Preview) free?

Yes. Graphviz Viewer & DOT Viewer (Live Preview) is free and MIT licensed.

How do I install Graphviz Viewer & DOT Viewer (Live Preview)?

Click "Install in VS Code" above, or search for zovo.zovo-graphviz-preview in the Extensions view.

What it does

The preview redraws 300 ms after you stop typing. You don't need to save. The status line shows the node and edge count, the engine and the layout time.

broken.dot with "check -> ;" on line 4. The editor underlines the semicolon and the status bar shows 1 error. The preview shows a red banner that reads "Line 4: syntax error near ';'"

Click the banner line to put the cursor on the error. Warnings, such as an unknown shape, show in the same banner in yellow and in Problems.

Pan, zoom, find and jump

Drag to pan. The mouse wheel and trackpad also pan, and Cmd or Ctrl plus the wheel zooms at the pointer. Fit and 1:1 reset the view, and the keys +, -, 0 and 1 do the same when the graph has focus.

Type in Find node to light up every node whose name or label matches. The rest fade out. Enter moves to the next match and centers it, and Shift+Enter goes back. Click any node, edge or cluster to put the cursor where it's written in the source. For a node that is the line where it's declared with attributes, or else its first edge.

The word "pay" in Find node. Payments is outlined and every other node is faded. The source shows the cursor on line 16, where payments is declared

Layout engines

Pick dot, neato, fdp, sfdp, circo or twopi from the toolbar. "auto" uses the layout= attribute of the graph, or dot when there is none. A layout= in the file wins over the picker, and the status line says so. Set the default for new previews with graphvizPreview.defaultEngine.

Dot blocks in Markdown

Fenced blocks with the language dot, graphviz or gv are drawn in VS Code's own Markdown preview. Run "Graphviz: Open Preview to the Side" in a Markdown file to get the full preview for one block. It follows the block under your cursor, and a picker lists them all.

design-notes.md with a dot block and a graphviz block. The built-in Markdown preview on the right draws both graphs between the paragraphs

Export

SVG saves the Graphviz output. PNG saves it at 2x on a white background. Both use the original Graphviz colors, not the dark-theme colors, so the file looks right in a document or a wiki. The save dialog starts next to the source file.

The order-state machine laid out with circo in a light theme, black on white as Graphviz draws it

Settings

SettingDefaultWhat it does
graphvizPreview.defaultEngineautoEngine for new previews
graphvizPreview.updateDelayMs300Wait after typing before redrawing
graphvizPreview.renderTimeoutSeconds15A longer layout is stopped and the preview says so
graphvizPreview.maxSourceKB4096Bigger graphs are not laid out
graphvizPreview.themeautoauto, light, dark or original colors
graphvizPreview.markdownPreviewtrueDraw dot blocks in the Markdown preview
graphvizPreview.markdownMaxBlockKB256Bigger blocks are not drawn in the Markdown preview
graphvizPreview.askForRatingtrueAsk one time for a Marketplace rating after a few days of use
graphvizPreview.showSupportLinkstrueShow the small Sponsor and More free viewers links under the graph

Privacy and safety

The extension makes no network calls and has no telemetry. The preview runs under a strict Content Security Policy with no remote sources. Graphviz output is cleaned before it's shown, which removes scripts, external links (URL and href attributes) and images. Label text is always shown as text. Graphviz runs on a virtual file system inside WebAssembly, so an image= attribute can't read files from your disk.

Limits

License

MIT. The bundled @viz-js/viz is MIT and contains Graphviz (Eclipse Public License 1.0). See THIRD-PARTY-NOTICES.md.

Install Graphviz Viewer & DOT Viewer (Live Preview)

Click the button to open VS Code and install it, or press Ctrl+P (Cmd+P on macOS) in VS Code and run ext install zovo.zovo-graphviz-preview.

Free, MIT license. Needs VS Code 1.90.0 or newer. Extension ID zovo.zovo-graphviz-preview, version 0.1.4.

Source code and issues are on GitHub.

All our VS Code extensions

Support this work

If this extension saves you time, you can support the work on GitHub Sponsors. Monthly tiers start at $5, and one-time tiers start at $15. Sponsorship is optional, and the tool works the same without it.