Skip to main content

Graphviz Preview

Draw Graphviz graphs from DOT source as you type.

Graphviz Preview

Switch layouts like dot, neato and sfdp, keep CJK labels inside shapes, and save SVG or PNG. No install.

Type DOT source on the left, and the graph is drawn on the right as soon as you pause.

The samples cover a process flow, an undirected network, clusters, record shapes, HTML-like labels, a state machine and an org chart.

Switch the layout engine (dot, neato, fdp, sfdp, circo, twopi, osage, patchwork) with the selector above the editor.

Graphviz Preview: Features

What Graphviz is

Graphviz is open source graph visualization software. It reads a graph written in the DOT language, works out where the nodes and edges go, and draws the result as SVG and other formats.

It suits anything made of points and lines: dependency graphs, state machines, org charts and network layouts.

This tool runs Graphviz 14.1.1 through Viz.js, the WebAssembly build for browsers. It is the same build that the PlantUML Preview uses to lay out its diagrams.

DOT basics

A DOT file names the kind of graph and then lists nodes and edges inside braces. The samples use the same building blocks.

Names made of letters, digits and underscores need no quotes. Put names with spaces or symbols in double quotes.

SyntaxMeaning
digraph name { … }A directed graph (edges are ->)
graph name { … }An undirected graph (edges are --)
A -> B [label="text"];An edge from A to B with a label
A [shape=box, label="text"];The shape and text of a node
rankdir=LR;Lay out from left to right (the default is top to bottom)
subgraph cluster_name { … }A subgraph whose name starts with cluster is drawn as a boxed group
{rank=same; A B}Put A and B on the same level (dot only)
// textA comment (/* … */ also works)

Layout engines

The same DOT source gives different drawings with different layout engines. The descriptions follow the official Graphviz documentation.

If the source itself sets layout=neato or similar, that setting takes precedence over the selector, as the documentation describes.

Dense graphs are slow with dot: in this tool, 300 nodes with 600 edges took about 30 seconds. Layouts are stopped after 20 seconds, so try sfdp or neato for large graphs.

EngineHow it drawsGood for
dotHierarchical, layered drawings of directed graphsProcess flows, dependencies, org charts
neatoSpring model layoutsSmall undirected graphs
fdpForce-directed placementNetworks with clusters
sfdpScalable force-directed placementGraphs with many nodes and edges
circoCircular layoutRings and cycles
twopiRadial layoutGraphs around one central node
osageDraws clustered graphsGraphs that are mainly groups
patchworkSquarified treemap of a clustered graphComparing sizes

Why CJK labels overflow, and how this tool fixes it

Graphviz in the browser cannot measure text with real fonts, so it estimates the width from a table. In our tests it counted each Japanese, Chinese or Korean character as 0.75 of a character wide.

Shapes and edge labels are therefore about a quarter too narrow, and CJK labels spill out of their boxes. Other editors built on browser versions of Graphviz can show the same problem.

This tool corrects the width estimate to one full character before layout and removes the correction afterwards. It works for node names, edge labels, cluster titles and record labels, and nothing extra is left in the saved SVG.

Text in an SVG file is drawn with the fonts of the computer that opens it. Save as PNG if the exact look of the text matters.

Graphviz, PlantUML or Mermaid?

All three turn text into diagrams, but each has its strengths.

  • For UML such as sequence and class diagrams, use the PlantUML Preview.
  • For diagrams written straight into Markdown on GitHub, use the Mermaid Preview.
  • For general graphs where you want control over placement, with layout engines, rank and cluster, use Graphviz.

Privacy and limits

Graphs are drawn inside your browser, and your source is never sent to a server. It is kept in your browser so you can continue later.

A browser page cannot read files from your computer, so the image attribute is not available. Links set with URL or href are not clickable in the preview, but they stay in the saved SVG.

Graphviz Preview: FAQ

Do Japanese, Chinese and Korean labels really fit?

Yes. The width estimate is corrected before layout, so the text stays inside the shapes with common fonts.

Some fonts are slightly narrower, which can leave a little extra space.

Can I paste DOT from the Python graphviz package or the dot command?

Yes, paste the DOT source.

This tool uses Graphviz 14.1.1, so the placement may differ from another Graphviz version.

Why does changing the layout do nothing?

Your source probably sets layout=…, which takes precedence. The tool shows a notice when that happens.

Remove the layout setting from the source to use the selector.

My large graph is not drawn. Why?

Layouts are stopped after 20 seconds. For large graphs with many edges, sfdp and neato are much faster than dot.

PNG files are scaled down to fit 8,192 px per side and an area limit.

The text looks different when I open the SVG on another computer.

SVG text is drawn with the fonts of the computer that opens the file. Save as PNG to fix the look of the text.

Is my source saved anywhere?

Only in your browser, never on a server. Press Clear to remove it.

How to Use Graphviz Preview

  1. Write DOT source

    Type DOT source on the left, or pick a sample to start from an example.

  2. Choose a layout

    Pick a layout engine such as dot or neato above the editor. The graph is redrawn immediately.

  3. Save the graph

    Press Save SVG or Save PNG. Copy SVG puts the SVG markup on your clipboard.

Category Design