49

I'm looking for an easy language/command line utility to draw sequence and timing diagrams (could be 2 different tools). I've already found Mscgen for sequence diagram drawing and looks pretty good, but I'm studying other possibilities.

Thanks

scravy
  • 11,904
  • 14
  • 72
  • 127
rnunes
  • 2,785
  • 7
  • 28
  • 56
  • mscgen seems the better choice to me for that task - see http://stackoverflow.com/questions/1491322/graphviz-top-to-bottom-and-left-to-right for implementing a sequence diagram with graphviz. – marapet Jun 16 '11 at 19:19
  • mscgen gets my vote. – philcolbourn Sep 08 '17 at 22:12

9 Answers9

35

PlantUML. http://plantuml.sourceforge.net/sequence.html

PlantUML is used to draw UML diagram, using a simple and human readable text description.

The generated images can then be used without any reference to the GPL/LGPL/ASL/EPL/MIT license. It is not even necessary to stipulate that they have been generated with PlantUML, although this will be appreciate by PlantUML team.

In my experience it has been easy to use and it produces nice looking diagrams. I can't recommend it more highly.

Output file types:

-tsvg     To generate images using SVG format
-teps     To generate images using EPS format
-txmi     To generate XMI file for class diagram
-thtml    To generate HTML files for class diagram
-ttxt     To generate images with ASCII art
-tutxt    To generate images with ASCII art using Unicode characters

Here is an example showing how to create a simple sequence diagram. enter image description here

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

Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml

You can also create more detailed diagrams by using lifeline activation and destruction: enter image description here

@startuml
participant User

User -> A: DoWork
activate A

A -> B: << createRequest >>
activate B

B -> C: DoWork
activate C
C --> B: WorkDone
destroy C

B --> A: RequestCreated
deactivate B

A -> User: Done
deactivate A

@enduml
user3226306
  • 359
  • 3
  • 5
30

The best software I've found and I usually use to make sequence diagrams from plain text is SDEdit. It's a Java tool, so you can use it in any operating system. And it's free software!

With this tool, you write the following:

#![SD ticket order]
ext:External[pe]
user:Actor
/order:Order[x]
db:TicketDB
acc:Account

ext:user.order a ticket!
user:order.new()
order:return=db.reserve(date,count)
db:return=acc.debit(cost)
acc:return=db.bonus(date,count)

to obtain this:

SDEdit example

sgmonda
  • 2,615
  • 1
  • 19
  • 29
  • 3
    I almost gave up with the error when I tried to use this for the first time. Do not be deterred by the spurious error it give you when you copy and paste an example from the browser when it loses the CRUCIAL blank line between the declarations and the links. Once you get over that, you'll find it's a neat tool. – Sridhar Sarnobat Mar 19 '14 at 23:11
20

For sequence diagrams, you may take a look at websequencediagrams - it creates nice looking diagrams and has a lot of functionalities (examples page). It's not a command line utility, but it does have its web-API.

ditaa creates nice looking diagrams from ascii source. Written in java, it can be called on the command line to convert ascii text to diagrams.

marapet
  • 54,856
  • 12
  • 170
  • 184
  • 1
    +1 Very cool tool. There's now a [bunch of plugins](http://www.websequencediagrams.com/embedding.html) for websequencediagrams too... – DNA Nov 15 '12 at 08:21
  • 1
    For an open source tool with similar syntax to websequencediagrams.com, you might want to have a look at PlantUML (http://plantuml.sourceforge.net/sequence.html). – user569825 Apr 07 '13 at 11:48
  • Websequencediagrams is great until it becomes too big to be readable, and unless you pay you don't get the option to export to anything except a PNG which is too blurry to read the text. – Sridhar Sarnobat Mar 19 '14 at 23:18
12

Another sequence diagram tool is http://sequencediagram.org where it's possible to draw the diagram to generate the script and script to get the diagram at the same time.

So, it's good for large diagrams where you normally lose track of where you are in the script.

enter image description here

Community
  • 1
  • 1
Staffan Persson
  • 151
  • 1
  • 5
7

update: probably mermaid is good enough, you can use it in various markdown editors, such as hackmd. Otherwise, for print, see my origina answer below.


This answers is maybe not exactly what you had in mind, so let me shortly give a context.

Over the years I've come to appreciate literate programming as a super nice way to write quality software and keep that code comprehensible. Maybe the only way... In any case, sequence diagrams, being visual, nicely complement code and writing. This facilitates understanding.

LaTeX / PGF / pgf-umlsd / noweb

So for this purpose, LaTeX + pgf-umlsd can create very good looking diagrams. They are specified semantically, like most other tools, meaning you say what sequence you what, not how it should look. The program computes the right picture.

So this LaTeX code

\documentclass{article}
\usepackage{tikz}
\usepackage{pgf-umlsd}

\begin{document}
\begin{sequencediagram}
  \newthread{t}{:Thread}
  \newinst[1]{i}{:Instance}
  \begin{sdblock}{Block}{description}
     \begin{call}{t}{function()}{i}{}
  \end{call}
  \end{sdblock}
\end{sequencediagram}
\end{document}

creates this picture (of course using the fonts of the rest of your document, etc.):

example from the manual

In the LaTeX source the relevant bits of executable code are just below the diagram, keeping things together. I use noweb (site, docs) to get the runnable code or the source for the article.

HTH.

wires
  • 4,718
  • 2
  • 35
  • 31
  • Can you provide a minimal working example (MWE) along with compile commands please. I find the manual doesn't indicate the preamble and `pdflatex` does not seem to want to compile it – puk Jul 23 '17 at 22:11
  • Just found a MWE. I forgot to add the `\documentclass{article}` and `\usepackage{pgf-umlsd}` preamble as well as the surrounding `\begin{document}...\end{document}` commands. https://tex.stackexchange.com/questions/185640/how-to-create-an-instance-in-pgf-umlsd – puk Jul 23 '17 at 22:16
  • Tried [mermaid](https://mermaidjs.github.io/) but don't like it. I feel its syntax is strictly defined, so even participant name with space or `-` is not supported. Instead, [PlantUML](http://plantuml.sourceforge.net/sequence.html) recommended by @user3226306 has similar syntax but is much better! – Yun Wu Dec 22 '21 at 00:33
2

GenMyModel now supports sequence diagrams.

Sequence sample

Xaelis
  • 1,609
  • 10
  • 17
1

EventStudio System Designer 5 might work for you. It generates sequence diagrams from text based input. Also handles multiple scenarios.

Sandeep
  • 648
  • 5
  • 12
1

For sequence diagrams, you also might want to look at UMLGraph.

Update 2018-08-24: web page seems to have moved to here.

sebastian
  • 1,438
  • 1
  • 15
  • 23
1

For sequence diagrams you may also want to look at Visual Paradigm, quite a powerful tool.

Darren Burgess
  • 4,200
  • 6
  • 27
  • 43