bmiller1009 / dot2img

Small library for converting DOT (graph description language) to various image formats

Version Matrix


Build Status Maven Central

Small library for converting DOT (graph description language) to various image formats (svg, jpeg, png)

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.


What things you need to install the software and how to install them

  • sbt 0.13 or greater if you want to build from source
  • JVM 8 for the Scala 2.12 build, JVM 6+ for the 2.11 build


If you're using Maven simply specify the GAV coordinate below and Maven will do the rest


Running with SBT

Add this GAV coordinate to your SBT dependency list

libraryDependencies += "org.bradfordmiller" %% "dot2img" % "0.0.21"

Building from source

Building the library requires SBT 0.13+ and a 1.8 version of the JDK for the Scala 2.12 version, or a 1.6+ version of the JDK for the Scala 2.11 version

You can build the library with this command

sbt publishLocal

The resulting jar will be published to ~/.ivy2/local/org/bradfordmiller/dot2img_{SCALA_VERSION}

Using the library

The library is quite simple. Feed in your dot grammar as a string along with an output path as seen below

import org.bradfordmiller.dot2img

//Set up your dot data
val data = "digraph G {\n  \"Welcome\" -> \"To\"\n  \"To\" -> \"Web\"\n  \"To\" -> \"GraphViz!\"\n}"

val p =, "/tmp/testformat.jpg")


The saved image will be at the path in the appropriately specified format. Currently svg, jpeg and png are supported.

The above code will produce the following image:

Test Graph

Built With

  • scala - The programming language
  • Apache Batik - SVG image conversion
  • viz.js - Javascript rendering engine for dot grammar


For the versions available, see the tags on this repository.


  • Bradford Miller - Initial work - bfm

See also the list of contributors who participated in this project.


This project is licensed under the Apache 2.0 License - see the LICENSE file for details


  • This library wraps viz.js to do the heavy lifting with the graphics rendering as seen here
  • Thanks to PurpleBooth for the README template as seen here