Atlas
  • All-in-one
  • Solutions
  • Compare
  • Pricing
PricingGet started
All guides
July 11, 2026·11 min read·graphviz, dot language, diagram as code, graphs

Graphviz and the DOT Language: A Complete Guide

Graphviz turns a plain-text description of nodes and edges into an automatically laid-out graph. This guide covers the DOT language, the attributes that control appearance, and the layout engines that place everything.

Graphviz is the original diagram-as-code tool: you describe a graph as nodes and edges in a simple language called DOT, and Graphviz computes a clean layout automatically. It has quietly powered a huge amount of technical diagramming for decades, and it sits underneath other tools too - PlantUML delegates much of its layout to Graphviz. If you have ever seen a tidy dependency graph or automaton diagram in documentation, there is a good chance DOT and Graphviz produced it.

This guide is a practical tour of DOT and Graphviz: the graph and digraph syntax, the node and edge attributes that control appearance, the rankdir and layout engines that determine placement, and subgraphs and clusters for structure. DOT is a text format, so you can reference any graph here and rebuild it as an editable, styled diagram in Atlas Diagram Studio at /diagrams. The diagram-as-code guide at /guides/diagram-as-code-guide sets the broader context, and /guides/plantuml-vs-graphviz compares Graphviz with the UML-focused PlantUML.

The core DOT syntax

A DOT file declares one graph. For a directed graph - arrows with direction - you write digraph G { ... } and connect nodes with the arrow operator, so digraph { a -> b } draws a pointing from a to b. For an undirected graph, use graph G { ... } and connect nodes with a double hyphen instead, so graph { a -- b } draws a plain line. The keyword and the edge operator must match: arrows with digraph and dashes with graph, or Graphviz will reject the file.

Nodes are created implicitly the first time you name them in an edge, exactly as in PlantUML, so you rarely declare them separately unless you want to set attributes. You can chain edges - a -> b -> c draws two edges in a line - and add many at once. Statements end with a semicolon, which is optional but conventional. That is the entire structural core: a graph type, a set of nodes, and the edges between them, all in a few lines of readable text.

Node and edge attributes

Appearance is controlled by attributes written in square brackets. Attach them to a node by naming it with a bracket list, so a [shape=box, label="Start", color=blue] sets that node's shape, label, and colour. Attach them to an edge the same way after the edge, so a -> b [label="yes", style=dashed] labels and dashes that connection. The attribute vocabulary is large but memorable, and a handful covers most needs.

  • shape: box, ellipse, circle, diamond, cylinder, and many more control a node's outline.
  • label: the text shown; supports line breaks and, with the record shape, structured multi-field labels.
  • color, fillcolor, and style=filled: set the outline colour and, when filled, the interior colour.
  • style: dashed, dotted, bold, or rounded change how a node or edge is drawn.
  • fontname, fontsize, and fontcolor: control typography for labels.
  • arrowhead: on directed edges, choose normal, vee, diamond, dot, or none to signal the relationship type.
  • Set defaults for all nodes or edges at once with a bare node [...] or edge [...] statement before the elements.

Layout direction and engines

By default Graphviz lays a directed graph out top to bottom, but you control the flow with the graph-level rankdir attribute. Set rankdir=LR at the top of the graph for a left-to-right layout, which suits wide process flows and pipelines far better than the default; TB, BT, and RL give the other three directions. The rank of a node - how far along the flow it sits - is computed automatically, but you can force nodes onto the same rank with a subgraph and rank=same when you need two things drawn side by side.

Graphviz is not one layout algorithm but several, exposed as different engines. The default, dot, produces the hierarchical layered layouts most people associate with Graphviz and is ideal for directed graphs like dependencies and flows. neato and fdp use force-directed placement for undirected relationship graphs, circo arranges nodes in a circle for cyclic structures, and twopi does radial layouts around a central node. Choosing the engine that matches your graph's nature - hierarchical, relational, cyclic, or radial - is the single biggest lever on how good the result looks.

Subgraphs, clusters, and real use

Structure comes from subgraphs. A subgraph whose name begins with cluster_ is drawn as a boxed, labelled grouping - subgraph cluster_frontend { label="Frontend"; a; b; } wraps nodes a and b in a titled rectangle, which is how you show subsystems, layers, or ownership boundaries. Non-cluster subgraphs do not draw a box but let you apply shared attributes or a rank=same constraint to a set of nodes. Clusters are the DOT equivalent of the packages and boundaries you use in other diagram languages.

Because DOT is text, it fits the same diagram-as-code discipline as PlantUML and Mermaid: keep the .dot file in the repository, review it in pull requests, and regenerate the image so it never drifts. Graphviz is especially well suited to generated graphs - many tools emit DOT because it is so simple to produce programmatically, which the guide at /guides/how-to-generate-diagrams-from-code explores. When you want a graph styled beyond DOT's automatic layout or edited collaboratively by non-technical colleagues, rebuild it in Atlas Diagram Studio at /diagrams, and see /guides/diagram-as-code-vs-gui-diagramming for when the text-first approach is worth it versus a visual editor.

Keep reading

  • Best Diagramming Software in 2026: The Overall Buyer Guide
  • How to Make Diagrams for Confluence
  • How to Make Diagrams for Notion
  • Free PDF tools
  • The all-in-one work OS

FAQ

Questions, answered.

What is the difference between graph and digraph in DOT?
digraph declares a directed graph whose edges are arrows written with the -> operator, as in digraph { a -> b }. graph declares an undirected graph whose edges are plain lines written with -- , as in graph { a -- b }. The graph keyword and the edge operator must match, or Graphviz rejects the file.
How do I change the direction a Graphviz diagram flows?
Set the graph-level rankdir attribute. The default is TB for top-to-bottom; use rankdir=LR for a left-to-right layout, which suits wide pipelines and process flows, or BT and RL for the other directions. Add it near the top of the graph, before or alongside your node and edge statements.
How do I style nodes and edges in DOT?
Attach attributes in square brackets. For a node, write its name followed by a bracket list such as a [shape=box, style=filled, fillcolor=lightblue]. For an edge, put the bracket list after it, such as a -> b [label="yes", style=dashed]. You can also set defaults for all nodes or edges with a bare node [...] or edge [...] statement.
What are the different Graphviz layout engines for?
Each engine suits a different graph shape. dot produces hierarchical layered layouts for directed graphs like dependencies and flows. neato and fdp use force-directed placement for undirected relationship graphs, circo arranges nodes in a circle for cyclic structures, and twopi does radial layouts. Matching the engine to your graph is the biggest factor in how good the result looks.

Ready when you are

One workspace, not ten.

Atlas replaces the stack with one platform for tasks, projects, CRM, contracts, e-signature, PDF tools, and analytics. Start free.

Get started freeSee pricing
AtlasWork, planned itself.

The AI-native, all-in-one work platform. Tasks, projects, CRM, contracts, and analytics in one calm workspace.

All systems operational
  • SOC 2 II
  • ISO 27001
  • HIPAA
  • GDPR

Product

  • Overview
  • PDF tools
  • People & HR
  • Integrations
  • Marketplace
  • Pricing

Resources

  • Guides
  • Docs
  • API reference
  • Support
  • Changelog
  • Status

Company

  • About
  • Careers
  • Press
  • Contact

Legal & trust

  • Trust center
  • Security
  • Privacy
  • Terms
  • DPA
  • GDPR
  • SLA
  • Refunds
Atlas, a product by wrxstack.com·© 2026 wrxstack·All rights reserved
PrivacyTermsSecurityStatus