DOT (graph description language)
File format
title: "DOT (graph description language)" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["mathematical-software", "graph-description-languages", "graph-drawing"] description: "File format" topic_path: "linguistics" source: "https://en.wikipedia.org/wiki/DOT_(graph_description_language)" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary File format ::
::data[format=table title="Infobox file format"]
| Field | Value |
|---|---|
| name | DOT |
| _noextcode | on |
| extensions | .gv |
| _nomimecode | on |
| mime | |
| type_code | |
| uniform_type | |
| conforms_to | |
| released | |
| latest_release_date | |
| genre | Graph description language |
| open | Yes |
| :: |
| name = DOT
| icon =
| iconcaption =
| screenshot =
| caption =
|_noextcode = on
| extensions = .gv
|_nomimecode = on
| mime =
| type_code =
| uniform_type =
| conforms_to =
| magic =
| developer =
| released =
| latest_release_version =
| latest_release_date =
| genre = Graph description language
| container_for =
| contained_by =
| extended_from =
| extended_to =
| standard =
| open = Yes
| url =
DOT is a graph description language, developed as a part of the Graphviz project. DOT graphs are typically stored as files with the .gv or .dot filename extension — .gv is preferred, to avoid confusion with the .dot extension used by versions of Microsoft Word before 2007. dot is also the name of the main program to process DOT files in the Graphviz package.
Various programs can process DOT files. Some, such as dot, neato, twopi, circo, fdp, and sfdp, can read a DOT file and render it in graphical form. Others, such as gvpr, gc, acyclic, ccomps, sccmap, and tred, read DOT files and perform calculations on the represented graph. Finally, others, such as lefty, dotty, and grappa, provide an interactive interface. The GVedit tool combines a text editor and a non-interactive viewer. Most programs are part of the Graphviz package or use it internally.
DOT is historically an acronym for "DAG of tomorrow", as the successor to a DAG format and a dag program which handled only directed acyclic graphs.
Syntax
Graph types
Undirected graphs
::figure[src="https://upload.wikimedia.org/wikipedia/commons/3/39/DotLanguageUndirected.svg" caption="An undirected graph"] ::
At its simplest, DOT can be used to describe an undirected graph. An undirected graph shows simple relations between objects, such as reciprocal friendship between people. The graph keyword is used to begin a new graph, and nodes are described within curly braces. A double-hyphen (--) is used to show relations between the nodes.
::code[lang=dot]
// The graph name and the semicolons are optional
graph graphname {
a -- b -- c;
b -- d;
}
::
Directed graphs
::figure[src="https://upload.wikimedia.org/wikipedia/commons/e/ec/DotLanguageDirected.svg" caption="A directed graph"] ::
Similar to undirected graphs, DOT can describe directed graphs, such as flowcharts and dependency trees. The syntax is the same as for undirected graphs, except the digraph keyword is used to begin the graph, and an arrow (-) is used to show relationships between nodes.
::code[lang=dot]
digraph graphname {
a -> b -> c;
b -> d;
}
::
Attributes
::figure[src="https://upload.wikimedia.org/wikipedia/commons/5/52/DotLanguageAttributes.svg" caption="A graph with attributes"] ::
Various attributes can be applied to graphs, nodes and edges in DOT files. These attributes can control aspects such as color, shape, and line styles. For nodes and edges, one or more attribute–value pairs are placed in square brackets [] after a statement and before the semicolon (which is optional). Graph attributes are specified as direct attribute–value pairs under the graph element, where multiple attributes are separated by a comma or using multiple sets of square brackets, while node attributes are placed after a statement containing only the name of the node, but not the relations between the dots.
::code[lang=dot] graph graphname { // This attribute applies to the graph itself size="1,1"; // The label attribute can be used to change the label of a node a [label="Foo"]; // Here, the node shape is changed. b [shape=box]; // These edges both have different line properties a -- b -- c [color=blue]; b -- d [style=dotted]; // [style=invis] hides a node. } HTML-like labels are supported, although initially Graphviz did not handle them.{{cite web|url=http://www.graphviz.org/doc/info/shapes.html#html|title=Node Shapes: HTML-Like Labels|website=graphviz.org|access-date=2017-05-12}}{{Clear}} ::
Comments
DOT supports C and C++ style single line and multiple line comments. In addition, it ignores lines with a number sign symbol # as their first character, like many interpreted languages.
Layout programs
::figure[src="https://upload.wikimedia.org/wikipedia/commons/c/c6/Huffman_(To_be_or_not_to_be).svg" caption="Binary tree generated in Graphviz from a DOT description by an online [http://huffman.ooz.ie/ Huffman Tree generator]"] ::
The DOT language defines a graph, but does not provide facilities for rendering the graph. There are several programs that can be used to render, view, and manipulate graphs in the DOT language:
General
- Graphviz – a collection of CLI utilities and libraries to manipulate and render graphs into different formats like SVG, PDF, PNG etc.
dot– CLI tool for conversion between and other formats
JavaScript
- Canviza JavaScript library for rendering DOT files
- d3-graphviza JavaScript library based on Viz.js and D3.js that renders DOT graphs and supports animated transitions between graphs and interactive graph manipulation
- Vis.jsa JavaScript library that accept DOT as input for network graphs.
- Viz.js – a JavaScript port of Graphviz that provides a simple wrapper for using it in the browser.
- hpcc-js/wasm Graphviza fast WASM library for Graphviz similar to Viz.js
Java
- Gephian interactive visualization and exploration platform for all kinds of networks and complex systems, dynamic and hierarchical graphs
- Grappaa partial port of Graphviz to Java
- graphviz-javaan open source partial port of Graphviz to Java available from github.com
- ZGRViewera DOT viewer
Other
- Beluginga Python- & Google Cloud Platform-based viewer of DOT and Beluga extensions
- Delineatea Rust application for Linux than can edit fully-featured DOT graph with interactive preview, and export as PNG, SVG, or JPEG
- dot2texa program to convert files from DOT to PGF/TikZ or PSTricks, both of which are rendered in LaTeX
- OmniGrafflea digital illustration application for macOS that can import a subset of DOT, producing an editable document (but the result cannot be exported back to DOT)
- Tulipa software framework in C++ that can import DOT files for analysis
- VizierFXan Apache Flex graph rendering library in ActionScript
Notes
References
- "File extension .dot or .gv?".
- (2022-11-14). "'dot' name (etymology)".
- "Node, Edge and Graph Attributes".
- "Node Shapes: HTML-Like Labels".
- "canviz: graphviz on a canvas".
- "GitHub - magjac/d3-graphviz: Graphviz DOT rendering and animated transitions using D3".
- "Import data in DOT language".
- "Github - Viz.js - Graphviz in your browser".
- "hpcc-js/wasm".
- "ZGRViewer".
- (2019-11-01). "dot2tex – A Graphviz to LaTeX converter".
- "Data Visualization Software – Tulip".
- "GitHub - gvhung/vizierfx: Automatically exported from code.google.com/p/vizierfx".
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::