How can I generate a UML sequence diagram from a file containing a textual representation of my process, with command-line tools in Linux?
7 Answers
Although PlantUML is listed in the accepted answer (among many other tools) it merits more attention.
In addition to being easily wrapped into a command line tool, PlantUML also has
- excellent documentation (check out the docs for sequence diagrams)
- simple and powerful syntax (may compare favorably with UMLGraph)
- styleable output
- extensive tool integration (Emacs, Sphinx)
However PlantUML comes as a java archive so the following setup may be required:
- java
- graphviz (not required for sequence diagrams)
- a bash wrapper
java and graphviz are available as packages for the major linux distros. PlantUML itself is available for Fedora and Ubuntu.
If your distribution does not provide a package, download a jar file from the main site and wrap as a bash script.
A bash wrapper (as follows) can be stored in a file named plantuml on your path i.e. one of the directories listed by echo $PATH
. Don't forget to make it executable with chmod u+x plantuml
.
#!/bin/bash
# from the vim syntax plugin README at aklt/plantuml-syntax on github
java -jar $HOME/path/to/plantuml.jar -tsvg $@
Then run plantuml apple.uml berry.uml
and plantuml will create apple.svg berry.svg.
There are many (many=more than 10) tools for this.
See a complete list.

- 17,291
- 7
- 48
- 81

- 8,058
- 2
- 33
- 39
Not sure if it's what you want, but UMLGraph can generate sequence diagrams using graphviz and ghostscript...

- 1,441
- 1
- 13
- 26
-
1Ghostscript isn't needed. GraphViz can directly generate PNG, SVG, and many other file types. – Diomidis Spinellis Jul 08 '10 at 14:09
-
@Diomidis: re-reading my comment, I realize I got several things mixed up: - GraphViz (alone) is used to generate class diagrams - the GNU plotutils (alone) are used to generate sequence diagrams. In some script I wrote a long time ago, I was using ghostscript to render the diagram at a high resolution. Then it was fed to ImageMagick to make the background transparent. See http://blog.julien.cayzac.name/2004/11/drawing-uml-sequence-diagrams-with-gnu.html – jcayzac Aug 04 '10 at 01:46
Put the following source into .html file and open it in a browser:
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function () {
$('textarea').each(function () {
$(this).hide();
var source = $(this).html();
$('body').append('<img src="http://yuml.me/diagram/scruffy/class/'
+ source + '" />');
});
});
</script>
</head>
<body>
<textarea>
[note: You can stick notes on diagrams too!{bg:cornsilk}],
[Customer]<>1-orders 0..*>[Order],
[Order]++*-*>[LineItem],
[Order]-1>[DeliveryMethod],
[Order]*-*>[Product],
[Category]<->[Product],
[DeliveryMethod]^[National],
[DeliveryMethod]^[International]
</textarea>
</body>
</html>
You should be able to see the sample diagram corresponding to the source within the textarea tag. Correct the source according to the yuml samples to draw your own diagram.

- 4,751
- 4
- 31
- 42
Use a script to replace:
- One space with multiple spaces
- Commas with column characters, such as
|
- Newline characters with carriage returns plus space indentation
- Dashes with multiple dashes
- Greater than and less than characters with column span characters
References

- 24,148
- 7
- 127
- 265