# Looking for tools outputting DOT files

**URL:** <https://forum.graphviz.org/t/looking-for-tools-outputting-dot-files/2496>\
**Category:** Help\
**Created:** [October 15, 2024, 2:31am UTC](https://forum.graphviz.org/t/looking-for-tools-outputting-dot-files/2496 "2024-10-15T02:31:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![halloleo](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/halloleo/32/1066_2.png) [@halloleo](https://forum.graphviz.org/u/halloleo)\
**Post date:** [October 15, 2024, 2:31am UTC](https://forum.graphviz.org/t/looking-for-tools-outputting-dot-files/2496/1 "2024-10-15T02:31:46Z")

</div>

I am looking for (software architecture) tools outputting DOT files.

GraphViz is very flexible, but this comes at a cost: E.g. using HTML tables to write nodes with a simple Above-and-below-a-line label

| Text Above Line |
| --------------------- |
| Text Below Line |

is pretty cumbersome.

Are there (preprocessor) tools known which make this and other things (like defining and using variables for colors, styles, etc) easier?

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [October 15, 2024, 4:08am UTC](https://forum.graphviz.org/t/looking-for-tools-outputting-dot-files/2496/2 "2024-10-15T04:08:21Z")

</div>

Don’t recall any general-purpose **dot** ([DOT Language | Graphviz](https://www.graphviz.org/doc/info/lang.html)) translators or style-sheet systems.  
But you can create **dot** filues using python, C, java, … interfaces and **[gvpr](https://www.graphviz.org/pdf/gvpr.1.pdf)**.  
For that matter, **dot** is a text-based language, so nearly any programming language can easily produce it.

There are outstanding requests for a style-sheet addition, but to my knowledge no one is working on it. Some folks use [M4](https://en.wikipedia.org/wiki/M4_(computer_language)) or [cpp](https://gcc.gnu.org/onlinedocs/cpp/) as pre-processors.

Note that you might not need an HTML-node to create text above & below a line, depending upon your specific formatting needs.

```auto
graph tlt {

  rankdir=LR
  
  a[label="1 text\n ____ \nmore text"]
  b[label="2 text\n------\nmore text"]
  c[label=<<U>3 text</U><BR/>more text>]
  d[label=<4 text<BR/>---------<br/>more text>]  
  /* or create labels elsewhere and insert as images */
}

```

![textLineText](https://global.discourse-cdn.com/graphviz/original/2X/f/f9816715bb505bbe9cf247decec2da87648582a9.png)

---

<div class="post-metadata">

**Author:** ![azriel](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/azriel/32/1138_2.png) [@azriel](https://forum.graphviz.org/u/azriel)\
**Post date:** [October 15, 2024, 4:27am UTC](https://forum.graphviz.org/t/looking-for-tools-outputting-dot-files/2496/3 "2024-10-15T04:27:50Z")

</div>

If you don’t mind a random yaml format, I made [https://azriel.im/dot\_ix](https://azriel.im/dot_ix)

The `node_descs:` key automatically inserts newlines according to the newlines in the string; and there is some styling support.

The generated dot file is in the second tab, but styles are generated on the page so you need tailwind plus some other processing to get the colors.

Otherwise, the generated svg is copied to clipboard when you click the second button from the top right when hovering over the diagram, which contains the styles inlined into the svg.

---

<div class="post-metadata">

**Author:** ![BartB](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@BartB](https://forum.graphviz.org/u/BartB)\
**Post date:** [October 15, 2024, 8:51pm UTC](https://forum.graphviz.org/t/looking-for-tools-outputting-dot-files/2496/4 "2024-10-15T20:51:43Z")

</div>

Have a look at this post.

> [@New Node Shape: Typed Node](https://forum.graphviz.org/t/new-node-shape-typed-node/2034):
>
> This is a continuation of [How to create a new node type? - #3 by Vithanco](https://forum.graphviz.org/t/how-to-create-a-new-node-type/1096/3). Thanks especially to [steveroush](https://forum.graphviz.org/u/steveroush) for the help provided then. I still think of node shapes. I would like to have a new node shape as used here: I will use “Typed Node” or “TNode” for this. So, a TNode shows a border (edge radius, thickness?) and a class name (font, size, colour) with a background colour - as in the picture. The node text is then shown inside the box. I believe the right way to create a TN…

And the answer @jjlong has posted refering to the excel to graphviz tool. [https://exceltographviz.com/](https://exceltographviz.com/)

I am using it for archtectural drawings using osage layouts for consistency of layering etc, see [Top Rank Node is not center aligned over some subgraphs](https://forum.graphviz.org/t/top-rank-node-is-not-center-aligned-over-some-subgraphs/2338)

---

<div class="post-metadata">

**Author:** ![halloleo](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/halloleo/32/1066_2.png) [@halloleo](https://forum.graphviz.org/u/halloleo)\
**Post date:** [October 17, 2024, 1:12am UTC](https://forum.graphviz.org/t/looking-for-tools-outputting-dot-files/2496/5 "2024-10-17T01:12:12Z")

</div>

Thanks for all the answers!

> [@steveroush](#):
>
> But you can create **dot** filues using python, C, java, …

That’s what I’m doing at the moment: Python and mustache templating. Works but feels very one-off-ish.

gvpr looks very powerful, though rather intimidating. Are there examples beyond the extensive man page?

> [@BartB](#):
>
> Have a look at this post.
> 
> [New Node Shape: Typed Node](https://forum.graphviz.org/t/new-node-shape-typed-node/2034)

Thanks for the link. This gives great options to create the node shapes I am looking for.

The other thing I really would like are _variables_ (for colours, etc) I can define and use in multiple places.

---

<div class="post-metadata">

**Author:** ![halloleo](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/halloleo/32/1066_2.png) [@halloleo](https://forum.graphviz.org/u/halloleo)\
**Post date:** [October 17, 2024, 1:17am UTC](https://forum.graphviz.org/t/looking-for-tools-outputting-dot-files/2496/6 "2024-10-17T01:17:02Z")

</div>

Maybe one day, when I have time (= never?) I write a little preprocessor in my new love child Scala 3. This preprocessor should do some form of:

- “node expansion” to define nodes with HTML-like labels in a simpler way.
- variable definition and use

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [October 17, 2024, 2:30am UTC](https://forum.graphviz.org/t/looking-for-tools-outputting-dot-files/2496/7 "2024-10-17T02:30:18Z")

</div>

You can find a set of smaller **gvpr** programs [here](https://gitlab.com/graphviz/graphviz/-/tree/main/cmd/gvpr/lib)  
and a set of larger **gvpr** programs [here](https://gist.github.com/steveroush)

Here is a hardcoded **gvpr** stylesheet:

```auto
BEG_G{
}
N{
  $.color="#4271C6"; // default
}
N[_type=="process"] {
  $.shape="Mrecord";
  $.style="filled";
  $.fillcolor="#E1F4FF";
  // maybe redo $.label
}
N[_type=="subprocess"] {
  $.shape="record";
  $.style="filled";
  $.color="#FFFFFF";
  $.fillcolor="#A5A5A5";
  $.label=sprintf("|%s|", $.label); // embed in pipes
}
N[_type=="database"] {
  $.shape="cylinder";
  $.color="#18589A";
}
N[_type=="inputoutput"] {
  $.shape="polygon";
  $.style='filled';
  $.fontcolor="white",
  $.ixedsize="true";
  $.skew="0.3";
  $.margin="0";
  $.width="2";
}
N[_type=="file"] {
  $.shape="folder";
}
N[_type=="external"] {
  $.shape="box3d";
}

```

And an accompanying .gv file

```auto
digraph pre{
  a [_type=process label="{1. Process\l | Something}"]
  b [_type=process label="{2. Process\l | Something else}"]
  c [_type=subprocess label="do it"]
  d [_type=database label="lots of data"]
  e [_type=database label="a bit of data"]
  f [_type=inputoutput label="inOut"]
  g [_type=file label="nail file"]
  h [_type=external label="outside"]  

 a->b->c->d->e->f->g->h
}

```

The trick is to generate the “stylesheet” real-time. Doable, but I could never come up with reasonable requirements.

---

<div class="post-metadata">

**Author:** ![halloleo](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/halloleo/32/1066_2.png) [@halloleo](https://forum.graphviz.org/u/halloleo)\
**Post date:** [October 20, 2024, 11:28pm UTC](https://forum.graphviz.org/t/looking-for-tools-outputting-dot-files/2496/8 "2024-10-20T23:28:28Z")

</div>

> [@steveroush](#):
>
> You can find a set of smaller **gvpr** programs [here](https://gitlab.com/graphviz/graphviz/-/tree/main/cmd/gvpr/lib)  
> and a set of larger **gvpr** programs [here](https://gist.github.com/steveroush)

Thanks for these! From the 2nd set of examples I can conclude that _you_ are quite a gvpr wiz!
