How to convert DOT graph to ASCII

The GraphViz DOT is a super-simple language that makes it very easy to create graphs and export them to various graphical formats. However, there are situations where you want to generate an ASCII graph. For example, to embed a flowchart or digraph in source code or documentation. GraphViz provides no exporter that can output an ASCII graph.

Thankfully, I found that this can be achieved using a Perl module called Graph::Easy. It can use GraphViz to understand your DOT file and then convert that to an elegant ASCII graph.

Here is how to use that:

  • We need to install the Graph::Easy module from CPAN. Make sure you have CPANMinus already installed, as described here. We install the Graph module like this:
$ sudo cpanm Graph::Easy
  • The Graph::Easy module installs a graph-easy program which we use to convert DOT graph to ASCII:

$ graph-easy

Tried with: Perl 5.22 and CPAN 1.61

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.