Warning

This page was moved to blockdiag.com. The reference page has moved to `blockdiag.com`_

Sample diagams

simple diagram

diagram {
   A -> B -> C -> D;
   A -> E -> F -> G;
}

diagram {
   A -> B -> C -> D;
   A -> E -> F -> G;
}

label attribute to nodes and edges

diagram {
   // Set labels to nodes.
   A [label = "foo"];
   B [label = "bar"];
   C [label = "baz"];

   // Set labels to edges. (short text only)
   A -> B [label = "click bar"];
   B -> C [label = "click baz"];
   C -> A;
}

diagram {
   // Set labels to nodes.
   A [label = "foo"];
   B [label = "bar"];
   C [label = "baz"];

   // Set labels to edges. (short text only)
   A -> B [label = "click bar"];
   B -> C [label = "click baz"];
   C -> A;
}

style attribute to nodes and edges

diagram {
   // Set boder-style and backgroun-color to nodes.
   A [style = dotted];
   B [style = dashed];
   C [color = pink];
   D [color = "#888888"];

   // Set border-style and color to edges.
   A -> B [style = dotted];
   B -> C [style = dashed];
   C -> D [color = "red"];

   // Set numbered-badge to nodes.
   E [numbered = 99];

   // Set background image to nodes (and erase label).
   F [label = "", background = "source/diagrams/python-logo.gif"];

   // Set arrow direction to edges.
   E -> F [dir = none];
   F -> G [dir = forward];
   G -> H [dir = back];
   H -> I [dir = both];
}

diagram {
   // Set boder-style and backgroun-color to nodes.
   A [style = dotted];
   B [style = dashed];
   C [color = pink];
   D [color = "#888888"];

   // Set border-style and color to edges.
   A -> B [style = dotted];
   B -> C [style = dashed];
   C -> D [color = "red"];

   // Set numbered-badge to nodes.
   E [numbered = 99];

   // Set background image to nodes (and erase label).
   F [label = "", background = "source/diagrams/python-logo.gif"];

   // Set arrow direction to edges.
   E -> F [dir = none];
   F -> G [dir = forward];
   G -> H [dir = back];
   H -> I [dir = both];
}

branched edges

New in version 0.7.5.

{
  // branching edges to multiple children
  A -> B, C;

  // branching edges from multiple parents
  D, E -> F;
}

{
  // branching edges to multiple children
  A -> B, C;

  // branching edges from multiple parents
  D, E -> F;
}

direction of edges

New in version 0.5.5.

{
  A -> B <- C -- D <-> E;
}

{
  A -> B <- C -- D <-> E;
}

edge folding

New in version 0.6.1.

{
  A -> B -> C -> D -> E;

  // fold edge at C to D (D will be layouted at top level; left side)
  C -> D [folded];
}

{
  A -> B -> C -> D -> E;

  // fold edge at C to D (D will be layouted at top level; left side)
  C -> D [folded];
}

mutlilingualization

diagram admin {
   // Set M17N text using label property.
   A [label = "起"];
   B [label = "承"];
   C [label = "転"];
   D [label = "結"];

   A -> B -> C -> D;

   // Use M17N text directly (need to quote).
   春 -> 夏 -> 秋 -> 冬;

   // Use M17N text including symbol characters (need to quote).
   "春は 曙" -> "夏 = 夜" -> "秋.夕暮れ" -> "冬 & つとめて";
}

Note

blockdiag supports UTF-8 encoding only.

diagram admin {
   // Set M17N text using label property.
   A [label = "起"];
   B [label = "承"];
   C [label = "転"];
   D [label = "結"];

   A -> B -> C -> D;

   // Use M17N text directly (need to quote).
   春 -> 夏 -> 秋 -> 冬;

   // Use M17N text including symbol characters (need to quote).
   "春は 曙" -> "夏 = 夜" -> "秋.夕暮れ" -> "冬 & つとめて";
}

shape of nodes

New in version 0.6.5: (experimental)

New in version 0.6.6: actor shape

New in version 0.8.2: dots shape

{
  // standard node shapes
  box [shape = "box"];
  roundedbox [shape = "roundedbox"];
  diamond [shape = "diamond"];
  ellipse [shape = "ellipse"];
  note [shape = "note"];

  cloud [shape = "cloud"];
  mail [shape = "mail"];
  beginpoint [shape = "beginpoint"];
  endpoint [shape = "endpoint"];
  minidiamond [shape = "minidiamond"];
  actor [shape = "actor"];
  dots [shape = "dots"];

  box -> roundedbox -> diamond -> ellipse;
  cloud -> note -> mail -> actor;
  minidiamond -> beginpoint -> endpoint -> dots;

  // node shapes for flowcharts
  condition [shape = "flowchart.condition"];
  database [shape = "flowchart.database"];
  input [shape = "flowchart.input"];
  loopin [shape = "flowchart.loopin"];
  loopout [shape = "flowchart.loopout"];
  terminator [shape = "flowchart.terminator"];

  condition -> database -> terminator -> input;
  loopin -> loopout;
}

{
  // standard node shapes
  box [shape = "box"];
  roundedbox [shape = "roundedbox"];
  diamond [shape = "diamond"];
  ellipse [shape = "ellipse"];
  note [shape = "note"];

  cloud [shape = "cloud"];
  mail [shape = "mail"];
  beginpoint [shape = "beginpoint"];
  endpoint [shape = "endpoint"];
  minidiamond [shape = "minidiamond"];
  actor [shape = "actor"];
  dots [shape = "dots"];

  box -> roundedbox -> diamond -> ellipse;
  cloud -> note -> mail -> actor;
  minidiamond -> beginpoint -> endpoint -> dots;

  // node shapes for flowcharts
  condition [shape = "flowchart.condition"];
  database [shape = "flowchart.database"];
  input [shape = "flowchart.input"];
  loopin [shape = "flowchart.loopin"];
  loopout [shape = "flowchart.loopout"];
  terminator [shape = "flowchart.terminator"];

  condition -> database -> terminator -> input;
  loopin -> loopout;
}

Using stacked attribute

New in version 0.8.2.

diagram {
  // Set stacked to nodes.
  stacked [stacked];
  diamond [shape = "diamond", stacked];
  database [shape = "flowchart.database", stacked];

  stacked -> diamond -> database;
}

diagram {
  // Set stacked to nodes.
  stacked [stacked];
  diamond [shape = "diamond", stacked];
  database [shape = "flowchart.database", stacked];

  stacked -> diamond -> database;
}

Using dots shape

New in version 0.8.2.

{
  A -> B, C, D;

  C [shape = "dots"];

  // hide edge forward to dots node
  A -> C [style = "none"];
}

{
  A -> B, C, D;

  C [shape = "dots"];

  // hide edge forward to dots node
  A -> C [style = "none"];
}

grouping nodes

New in version 0.5.3: label attributes for group

New in version 0.6: nested groups

New in version 0.7.5: group definition within node-attributes

diagram admin {
   A -> B -> C -> D;
   A -> E;
   A -> H;

   // A and B belong to first group.
   group {
      A; B;
   }

   // E, F and G belong to second group.
   group second_group {
      // Set group-label
      label = "second group";

      // Set background-color to this group.
      color = "#77FF77";

      E -> F -> G;

      // H and I belong to third "nested" group.
      group {
          color = "#7777FF";
          H -> I;
      }
   }

   // J belongs to second group
   J [group = second_group];
}

diagram admin {
   A -> B -> C -> D;
   A -> E;
   A -> H;

   // A and B belong to first group.
   group {
      A; B;
   }

   // E, F and G belong to second group.
   group second_group {
      // Set group-label
      label = "second group";

      // Set background-color to this group.
      color = "#77FF77";

      E -> F -> G;

      // H and I belong to third "nested" group.
      group {
          color = "#7777FF";
          H -> I;
      }
   }

   // J belongs to second group
   J [group = second_group];
}

diagram attributes

New in version 0.7.2: default_shape

diagram {
  // Set node metrix
  node_width = 200;  // default value is 128
  node_height = 100;  // default value is 40

  // Set span metrix
  span_width = 240;  // default value is 64
  span_height = 120;  // default value is 40

  // Set fontsize
  fontsize = 20;  // default value is 11

  // set default shape
  default_shape = roundedbox;  // default value is 'box'

  A -> B [label = "Use long long\nedge label"];
  A -> C;
}

diagram {
  // Set node metrix
  node_width = 200;  // default value is 128
  node_height = 100;  // default value is 40

  // Set span metrix
  span_width = 240;  // default value is 64
  span_height = 120;  // default value is 40

  // Set fontsize
  fontsize = 20;  // default value is 11

  // set default shape
  default_shape = roundedbox;  // default value is 'box'

  A -> B [label = "Use long long\nedge label"];
  A -> C;
}

portrait mode

New in version 0.7.0.

{
  orientation = portrait

  A -> B -> C;
       B -> D;
}

{
  orientation = portrait

  A -> B -> C;
       B -> D;
}

portrait group

New in version 0.7.4.

{
  A -> B -> C;

  group {
    orientation = portrait

    C -> D -> E;
  }
}

{
  A -> B -> C;

  group {
    orientation = portrait

    C -> D -> E;
  }
}

Simple diagram for master data manager

diagram admin {
  index [label = "List of FOOs"];
  add [label = "Add FOO"];
  add_confirm [label = "Add FOO (confirm)"];
  edit [label = "Edit FOO"];
  edit_confirm [label = "Edit FOO (confirm)"];
  show [label = "Show FOO"];
  delete_confirm [label = "Delete FOO (confirm)"];

  index -> add  -> add_confirm  -> index;
  index -> edit -> edit_confirm -> index;
  index -> show -> index;
  index -> delete_confirm -> index;
}

diagram admin {
  index [label = "List of FOOs"];
  add [label = "Add FOO"];
  add_confirm [label = "Add FOO (confirm)"];
  edit [label = "Edit FOO"];
  edit_confirm [label = "Edit FOO (confirm)"];
  show [label = "Show FOO"];
  delete_confirm [label = "Delete FOO (confirm)"];

  index -> add  -> add_confirm  -> index;
  index -> edit -> edit_confirm -> index;
  index -> show -> index;
  index -> delete_confirm -> index;
}