In a previous post I talk about Mermaid, a diagramming and charting tool. Now, I’m going to show you similar tools that also render diagrams from text definitions, so you can compare them and choose the one that suits you best.

Table of Contents

PlantUML

PlantUML is a Java-based tool to create diagrams from text descriptions. Just download the JAR file. You need to have Java Runtime Engine installed on your system, but it will be likely already installed. Graphviz is an optional dependency (needed for some diagram types).

Create a text file to define your diagram. As an example, paste this and save the file:

@startuml
A -> B: request
A <- B: response
@enduml

PlantUML can be used from the command-line or with a GUI (graphical user interface). Double-click on the JAR file to run the GUI. Select the directory where the text file is located and PlantUML will automatically create a PNG file wherever the text file is saved.

PlantUML

PlantUML

If you prefer the command-line, run this command (where the JAR file is located) to generate a PNG file from a text definition:

java -jar plantuml.jar <text file>

To generate an SVG, add -tsvg:

java -jar plantuml.jar -tsvg sequence.txt

To learn more about the diagram definition syntax, check https://plantuml.com/.

D2

This diagram scripting language can be installed with the following command (it’s recommended to check the installation file content before running the command):

curl -fsSL https://d2lang.com/install.sh | sh -s --
  • Root permissions are not required, it will be installed on $HOME/.local.

You can also install it with Go:

go install oss.terrastruct.com/d2@latest

After installed, create a text file (with the .d2 extension) and paste this:

x -> y: request

Save the file and run the following command. An SVG file will be created:

d2 <text file>
# d2 mydiagram.d2

To change the output filename, just add it after the text file:

d2 mydiagram.d2 output.svg

Use the same syntax to create a PNG image (the first time D2 will download some required dependencies):

d2 mydiagram.d2 output.png

Get more info about diagramming definition syntax on https://d2lang.com/tour/hello-world, and run d2 --help to find info about available command line parameters, such as -w to watch for changes and do a live reload.

If you have any suggestion, feel free to contact me via social media or email.