MediaWiki extensions manual
OOjs UI icon advanced-invert.svg
Release status: unmaintained
GraphViz Logo.png
Implementation Tag
Description Provides an online graph renderer
Latest version 3.1.0 (2018-03-13)
MediaWiki 1.29.x - 1.32.x only
PHP 5.4+
Composer mediawiki/graph-viz
License GNU General Public License 2.0 or later
  • $wgGraphVizDefaultImageType
  • $wgGraphVizExecPath
  • $wgGraphVizMscgenPath
Quarterly downloads 20 (Ranked 148th)
Public wikis using 168 (Ranked 429th)
Translate the GraphViz extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

The GraphViz extension lets you create and display graphs as in-line images on wiki pages using tools from the open-source Graphviz and Mscgen projects:


MediaWiki GraphViz Semantic Result Formats
1.27.x - 1.28.x 2.x.x 2.5.x
1.27.x - 1.28.x 2.x.x 3.0.x
1.29.x - 1.32.x 3.x.x 3.0.x
1.33+ Not compatible, use the Diagrams or External Data extension

see http://wiki.bitplan.com/index.php/GraphViz_MediaWiki_extension and http://wiki.bitplan.com/index.php/Diagrams for current discussion about replacing this extension with a somewhat compatible solution.


From the MediaWiki Extension DistributorEdit

Download from Special:ExtensionDistributor/GraphViz

With ComposerEdit

GraphViz should be installed using built-in Composer support. The package name is mediawiki/graph-viz. For instructions on how to install Composer see MediaWiki's user manual for Composer.

Once you have Composer properly installed, go to your MediaWiki installation directory and add the extension to your to your composer.local.json:

  "require": {
    "mediawiki/graph-viz": "^3.1"

And then run:

composer update

Without ComposerEdit

  1. Download the GraphViz extension archive from GIT and extract it into your MediaWiki "/extensions/GraphViz" directory.


  1. Update LocalSettings.php to include the following:
    wfLoadExtension( 'GraphViz' );
  2. Visit your wiki's Special:Version page and verify that the correct version of the GraphViz extension is installed.
  3. Install one of the external tools "Graphviz" or "Mscgen".
    1. Windows: Get your copy here: http://www.graphviz.org/Download.php or here http://www.mcternan.me.uk/mscgen/
    2. Unix: Same links as for windows but normally it should be pre-installed (at least graphviz - search for dot) or can be found in the package manager.
    3. Ubuntu/Debian:
      sudo apt-get install graphviz
      sudo apt-get install mscgen
  • Make sure that write permissions for the "$IP/images" directory are granted.
  • Make sure that internet users get read/execute access on your executables if you use server installations (especially under Windows).


Set configuration parameters in LocalSettings.php only if the defaults do not suit your environment.

Configuration variables
Variable name Platform Default Value Description Version
$wgGraphVizExecPath Windows C:/Program Files/Graphviz/bin/ Path of the directory containing the Graphviz executables (dot.exe, circo.exe, fpdp.exe, neato.exe, twopi.exe) all
Unix/linux /usr/bin/ Path of the directory containing the Graphviz executables (dot, circo, fdp, neato, twopi) all
$wgGraphVizMscgenPath all <none> Path to the mscgen executable all
$wgGraphVizDefaultImageType all png Default output image type if none is specified on the "format" attribute of an individual graph >= 1.0

Note: Under Linux, shell commands such as the Graphviz and mscgen executables are invoked with the limits given by $wgMaxShellTime, $wgMaxShellMemory and $wgMaxShellFileSize. If graphs or message sequence charts do not render then you may need to tune these settings for your installation.

Drawing GraphsEdit

You may define a graph in the dot language and enclose it in graphviz tags as follows:


You may define a message sequence chart in the mscgen language and enclose it in mscgen tags as follows:


When the wiki page is saved (or when you click "Show preview" after editing) an image is produced that corresponds to the DOT or mscgen text and it is shown in-line on the page. The image is also uploaded so it may be included in other pages directly.

See the #Examples for some basic graphs.

Graph Tag AttributesEdit

Graph tag attributes may be supplied with either graphviz or mscgen as follows:

<graphviz attr1="value1" attr2="value2" ... attrN="valueN">
<mscgen attr1="value1" attr2="value2" ... attrN="valueN">

The following extended image syntax attributes are supported as graph tag attributes: type, border, location, alignment, size, link, alt, caption.

Attribute Tag Description Value Version
format graphviz specifies the graph image output format gif, jpg, jpeg, png, svg* all
format mscgen specifies the message sequence chart image output format png, svg* all
uniquifier graphviz needed to display graphs of the same name on the same page (rare) text (appended to the graph name) >=1.0
uniquifier mscgen needed to display multiple message sequence charts on the same page (common) text (used as message sequence chart name) >=1.0
renderer graphviz see "layout commands" in the Graphviz documentation dot, neato, fdp, sfdp, circo, twopi all
preparse graphviz replace magic words before invoking the graphviz renderer dynamic >=1.5.0
preparse mscgen replace magic words before invoking the mscgen command dynamic >=1.5.0

The option preparse="dynamic" makes it also possible to use GraphViz and templates and import these into a MediaWiki site. Changes to the original template will then be passed on. No preparse option will lead to two images, in case of a change to the original, of which the older version will always be imported should the template be called.

  • svg requires additional configuration.

Multiple Graphs Per PageEdit

For graphviz, use unique names for each graph to display multiple graphs on the same page.

First Graph Second Graph
graph NAME {...
graph ANOTHERNAME {...

For mscgen, use the "uniquifier" tag attribute to display multiple message sequence charts on the same page.

First Message Sequence Chart Second Message Sequence Chart
<mscgen uniquifier="NAME">
msc {...
<mscgen uniquifier="ANOTHERNAME">
msc {...


Graphs in the DOT and mscgen languages may include URLs. These follow the pattern URL="link" where "link" is governed by the ImageMap syntax:

"All links are given in either the form [[Page title]] or [[Page title|description]]. In the latter case, the part after the pipe becomes the title attribute of the link—in most browsers, it will pop up as a tooltip when the user hovers over it; the part after the pipe also becomes the alt text for the link. If no explicit link description is given, the page title is used."

Additionally, external links are supported with or without square brackets. Specify external links without square brackets in order to honor DOT tooltip attributes (e.g. URL="http://mediawiki.org", tooltip="MediaWiki"). The MediaWiki "external link with different label" form is also supported (e.g. [http://mediawiki.org MediaWiki]).


The link format is different from the format used in earlier versions. ( < 1.0).

See #Example 3 for an example with links.

Finding graphs and message sequence chartsEdit

Pages with graphs or message sequence charts will have the "graphviz" page property set. Using Special:PagesWithProp, you can find pages that have graphs or message sequence charts. (Example query for the English Wikipedia.)


This extension imposes the following restrictions on the DOT language input:

  • Any image attribute values are required to be the names of uploaded files.
  • Any IMG SRC attribute values in HTML-like labels are required to be the names of uploaded files.
  • The imagepath attribute is not allowed.
  • The shapefile attribute is not allowed.
  • The fontpath attribute is not allowed.


In addition to the examples below, here is a nice flickr gallery of graphviz-rendered graphs.

Example 1Edit

Graph for example no. 1
<graphviz border='frame' format='png' caption='Graph for example no. 1'>
digraph example1 {Hello->World}

Example 2Edit

Graph for example no. 2
<graphviz renderer="neato" caption="Graph for example no. 2">
graph example2 {
  run -- intr;
  intr -- runbl;
  runbl -- run;
  run -- kernel;
  kernel -- zombie;
  kernel -- sleep;
  kernel -- runmem;
  sleep -- swap;
  swap -- runswap;
  runswap -- new;
  runswap -- runmem;
  new -- runmem;
  sleep -- runmem;

Example 3Edit

Graph for example no. 3 (contains Wiki-Links)
<graphviz caption="Graph for example no. 3 (contains Wiki-Links)" alt="phylogenetic tree" format="png">
digraph example3 {
  node [shape=plaintext];
  Mollusca [URL="[[w:Mollusca]]"];
  Neomeniomorpha [URL="[[w:Neomeniomorpha]]"];
  X1 [shape=point,label=""];
  Caudofoveata [URL="[[w:Caudofoveata]]"];
  Testaria [URL="[[w:Testaria]]"];
  Polyplacophora [URL="[[w:Polyplacophora]]"];
  Conchifera [URL="[[w:Conchifera]]"];
  Tryblidiida [URL="[[w:Tryblidiida]]"];
  Ganglioneura [URL="[[w:Ganglioneura]]"];
  Bivalvia [URL="[[w:Bivalvia]]"];
  X2 [shape=point,label=""];
  X3 [shape=point,label=""];
  Scaphopoda [URL="[[w:Scaphopoda]]"];
  Cephalopoda [URL="[[w:Cephalopoda]]"];
  Gastropoda [URL="[[w:Gastropoda]]"];
  Ganglioneura ->Bivalvia

Example 4Edit

Message sequence chart for example no. 4
<mscgen caption="Message sequence chart for example no. 4">
msc {

  a->b  [label="ab()"];
  b->c  [label="bc(TRUE)"];
  c=>c  [label="process(1)"];
  c=>c  [label="process(2)"];
  c=>c  [label="process(n)"];
  c=>c  [label="process(END)"];
  a<<=c [label="callback()"];
  ---   [label="If more to run", ID="*"];
  a->a  [label="next()"];
  a->c  [label="ac()"];
  b<-c  [label="cb(TRUE)"];
  b->b  [label="stalled(...)"];
  a<-b  [label="ab() = FALSE"];

Contributions and historyEdit



The GraphViz extension depends on Extension:ImageMap as of version 1.0.

The following extensions depend on the GraphViz extension:

See alsoEdit