DEV Community

Renato Suero
Renato Suero

Posted on

Generate UML diagram from a textual description

Hi everyone,

I always hated UML because every tool I saw, I needed to "draw", I feel that I'm less productive.
So I found PlantUML and my world changed, now I could write and generate the diagram. One of the reasons I liked that option is to keep the diagrams updated, now it is simple and fast (to me).

Let's see how we can use the tool.
Firstly, another thing nice to me, I can use docker =).
I use 2 docker images, first to generate the diagram to me. I use https://hub.docker.com/r/think/plantuml/
In this case, I created a file called test.uml:

@startuml
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response

autonumber 15
Bob -> Alice : Another authentication Request
Bob <- Alice : Another authentication Response

autonumber 40 10
Bob -> Alice : Yet another authentication Request
Bob <- Alice : Yet another authentication Response

@enduml
Enter fullscreen mode Exit fullscreen mode

I run this command

cat test.uml | docker run --rm -i think/plantuml > test.svg 
cat test.uml | docker run --rm -i think/plantuml > test.png 
Enter fullscreen mode Exit fullscreen mode

As you can see, that's the result.
Diagram generated

Another way, I run the server to write and see the diagram. I use https://hub.docker.com/r/plantuml/plantuml-server/

In this case, I run the command

docker run -d -p 8080:8080 plantuml/plantuml-server:jetty
Enter fullscreen mode Exit fullscreen mode

then, I open my browser and I access http://localhost:8080. As you can see, that's the result.
plantUML as a server

If you want to play now you can use the official server, the good thing to use that server, is you can share the diagram

I recommend you access the official documentation, my goal was to show you options to generate your diagrams and help you to be more productive.

I'd like to show you a suggestion how to use dev.to using UML =)
Activity to read posts at dev.to

I'd like to invite you to write/draw a diagram and share here in the comments, let's inspire others readers =)

Top comments (8)

Collapse
 
aergonaut profile image
Chris Fung

Seems pretty similar to mermaid.js. The syntax for sequence diagrams is similar, and mermaid.js has an online editor, so you don't need to download and run a docker image yourself.

Collapse
 
renatosuero profile image
Renato Suero

Hi Chris,
I'll see the mermaid.js, it seems cool =)

plantUML has an online editor too plantuml.com/plantuml/uml/SyfFKj2r...

Collapse
 
jacebenson profile image
Jace

I'm a huge fan of these things as they can simplify what you're going to make for users.
I just use mermaidjs on workflow.jace.pro but on that list @jordi shared is an amazing thing called chartmage.com and that looks amazing

Collapse
 
renatosuero profile image
Renato Suero

Thanks @jacebenson . I'll test the tool =)

Collapse
 
jcabot profile image
Jordi Cabot

If you're into textual modeling, you may want to checkout these other textual UML tools as well : modeling-languages.com/text-uml-to...

(I do think that PlantUML is probably the best one but that also depends on your goals/ needs)

Collapse
 
renatosuero profile image
Renato Suero

Hey Jordi,

Thank you I'll check the tools if I find another cool tool, I write a new post about that

Collapse
 
npandey25 profile image
nitish pandey

Websequencediagrams.com doing this for years and very well

Collapse
 
renatosuero profile image
Renato Suero

great tool =)