ASCII Art

It is possible to generate Sequence Diagrams using ASCII art.

@startuml
participant Bob
actor Alice

Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml

You have to use the -txt flag in the command line, or the format tag in the Ant task :

<target name="main">
  <plantuml dir="./src" format="txt" />
</target>

Generated files use .atxt extension. ("a" as ASCII art : to NOT overide any existing .txt files!). Here is the result:

                      ,-.
                      `-'
                      /|\
     ,---.             |
     |Bob|            / \
     `-+-'           Alice
       |    hello      |
       |-------------->|
       |               |
       |  Is it ok?    |
       |<- - - - - - - |
     ,-+-.           Alice
     |Bob|            ,-.
     `---'            `-'
                      /|\
                       |
                      / \

You can control the maximum number of characters between participants by using skinparam maxAsciiMessageLength. This can be helpful if you need to limit the width of your ASCII Art.

For example:

@startuml
skinparam maxAsciiMessageLength 8
participant Bob
actor Alice

Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml

Will look like:

          ,-.  
          `-'  
          /|\  
 ,---.     |   
 |Bob|    / \  
 `-+-'   Alice 
   |hello  |   
   |------>|   
   |       |   
   Is it ok?   
   |<------|   
 ,-+-.   Alice 
 |Bob|    ,-.  
 `---'    `-'  
          /|\  
           |   
          / \  

Unicode

Das Standardformat txt verwendet nur einfache ASCII-Zeichen. Es ist möglich, einige erweiterte Unicode-Zeichen zu verwenden, um ein etwas besseres Ergebnis zu erzielen. Sie sollten das -utxt Flag in der Befehlszeile oder das utxt Format in der Ant Aufgabe verwenden.

                      ┌─┐
                      ║"│
                      └┬┘
                      ┌┼┐
     ┌───┐             │
     │Bob│            ┌┴┐
     └─┬─┘           Alice
       │    hello      │
       │──────────────>│
       │               │
       │  Is it ok?    │
       │<─ ─ ─ ─ ─ ─ ─ │
     ┌─┴─┐           Alice
     │Bob│            ┌─┐
     └───┘            ║"│
                      └┬┘
                      ┌┼┐
                       │
                      ┌┴┐

Die Verwendung von utxt hat zwei Nachteile:

  • Das Ergebnis ist UTF-8 kodiert, und das ist manchmal ein Problem (Mail-Gateway, Editoren...)
  • Die verwendete Schriftart muss die verwendeten erweiterten Zeichen haben (wie Courier, Courier New...)

Complex Diagram

You can even try complex example if you wish.

@startuml
'hide footbox

participant "Bob on\nseveral lines" as Bob
actor Alice

Bob -> Alice : hello
note right of Alice
  this is a note
end note

Alice -> Bob : Is it ok\nwith a message that is\non several lines?

note right
  This other note
  should work
  on several lines
end note

== This is a separation ==

Bob -> Last : Yes it works!
Last -> Last : working in progress
note left : this is\nanother note

Last --> Last : working in progress

Last --> Bob : done

opt dummy comment
  Bob -> Last : Error\nOn\nSeveral\nLine
  Last --> Bob : None
else
  Last --> Bob : None
  Last -> Bob : None
else other
  Last -> Bob : None
  note over Alice, Last
    This is a long note
    over Alice and Last
  end note
  Last -> Bob : None
  Last -> Bob : None
end
@enduml

Result

                                             ,-.
                                             `-'
               ,-------------.               /|\
               |Bob on       |                |             ,----.
               |several lines|               / \            |Last|
               `------+------'              Alice           `-+--'
                      |        hello          |               |
                      |---------------------->|               |
                      |                       |               |
                      |                       | ,--------------!.
                      |                       | |this is a note|_\
                      |                       | `----------------'
                      |Is it ok               | ,----------------!.
                      |with a message that is | |This other note |_\
                      |on several lines?      | |should work       |
                      |<----------------------| |on several lines  |
                      |                       | `------------------'
                      |                       |               |
                      |              ======================== |
====================================== This is a separation =======================================
                      |              ======================== |
                      |                       |               |
                      |            Yes it works!              |
                      |-------------------------------------->|
                      |                       |               |
                      |                       ,------------!. |----.
                      |                       |this is     |_\|    | working in progress
                      |                       |another note  ||<---'
                      |                       `--------------'|
                      |                       |               |- - .
                      |                       |               |    | working in progress
                      |                       |               |< - '
                      |                       |               |
                      |                 done  |               |
                      |<- - - - - - - - - - - - - - - - - - - |
                      |                       |               |
     ______________________________________________________________________
     ! OPT  /  dummy comment                  |               |            !
     !_____/          |                       |               |            !
     !                |                       |               |            !
     !                |               Error   |               |            !
     !                |               On      |               |            !
     !                |               Several |               |            !
     !                |               Line    |               |            !
     !                |-------------------------------------->|            !
     !                |                       |               |            !
     !                |                 None  |               |            !
     !                |<- - - - - - - - - - - - - - - - - - - |            !
     !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
     !                |                       |               |            !
     !                |                 None  |               |            !
     !                |<- - - - - - - - - - - - - - - - - - - |            !
     !                |                       |               |            !
     !                |                 None  |               |            !
     !                |<--------------------------------------|            !
     !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
     ! [other]        |                       |               |            !
     !                |                 None  |               |            !
     !                |<--------------------------------------|            !
     !                |                       |               |            !
     !                |                    ,-------------------!.          !
     !                |                    |This is a long note|_\         !
     !                |                    |over Alice and Last  |         !
     !                |                    `---------------------'         !
     !                |                 None  |               |            !
     !                |<--------------------------------------|            !
     !                |                       |               |            !
     !                |                 None  |               |            !
     !                |<--------------------------------------|            !
     !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
               ,------+------.              Alice           ,-+--.
               |Bob on       |               ,-.            |Last|
               |several lines|               `-'            `----'
               `-------------'               /|\
                                              |
                                             / \

Same example using Unicode

                                             ┌─┐
                                             ║"│
                                             └┬┘
               ┌─────────────┐               ┌┼┐
               │Bob on       │                │             ┌────┐
               │several lines│               ┌┴┐            │Last│
               └──────┬──────┘              Alice           └─┬──┘
                      │        hello          │               │
                      │──────────────────────>│               │
                      │                       │               │
                      │                       │ ╔═════════════╧══╗
                      │                       │ ║this is a note ░║
                      │                       │ ╚═════════════╤══╝
                      │Is it ok               │ ╔═════════════╧════╗
                      │with a message that is │ ║This other note  ░║
                      │on several lines?      │ ║should work       ║
                      │<──────────────────────│ ║on several lines  ║
                      │                       │ ╚═════════════╤════╝
                      │                       │               │
                      │              ╔════════╧═════════════╗ │
══════════════════════╪══════════════╣ This is a separation ╠═╪════════════════════════════════════
                      │              ╚════════╤═════════════╝ │
                      │                       │               │
                      │            Yes it works!              │
                      │──────────────────────────────────────>│
                      │                       │               │
                      │                       ╔══════════════╗│────┐
                      │                       ║this is      ░║│    │ working in progress
                      │                       ║another note  ║│<───┘
                      │                       ╚══════════════╝│
                      │                       │               │─ ─ ┐
                      │                       │               │    | working in progress
                      │                       │               │< ─ ┘
                      │                       │               │
                      │                 done  │               │
                      │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │
                      │                       │               │
     ╔══════╤═════════╪═══════════════════════╪═══════════════╪════════════╗
     ║ OPT  │  dummy comment                  │               │            ║
     ╟──────┘         │                       │               │            ║
     ║                │                       │               │            ║
     ║                │               Error   │               │            ║
     ║                │               On      │               │            ║
     ║                │               Several │               │            ║
     ║                │               Line    │               │            ║
     ║                │──────────────────────────────────────>│            ║
     ║                │                       │               │            ║
     ║                │                 None  │               │            ║
     ║                │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │            ║
     ╠════════════════╪═══════════════════════╪═══════════════╪════════════╣
     ║                │                       │               │            ║
     ║                │                 None  │               │            ║
     ║                │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │            ║
     ║                │                       │               │            ║
     ║                │                 None  │               │            ║
     ║                │<──────────────────────────────────────│            ║
     ╠════════════════╪═══════════════════════╪═══════════════╪════════════╣
     ║ [other]        │                       │               │            ║
     ║                │                 None  │               │            ║
     ║                │<──────────────────────────────────────│            ║
     ║                │                       │               │            ║
     ║                │                    ╔══╧═══════════════╧══╗         ║
     ║                │                    ║This is a long note ░║         ║
     ║                │                    ║over Alice and Last  ║         ║
     ║                │                    ╚══╤═══════════════╤══╝         ║
     ║                │                 None  │               │            ║
     ║                │<──────────────────────────────────────│            ║
     ║                │                       │               │            ║
     ║                │                 None  │               │            ║
     ║                │<──────────────────────────────────────│            ║
     ╚════════════════╪═══════════════════════╪═══════════════╪════════════╝
               ┌──────┴──────┐              Alice           ┌─┴──┐
               │Bob on       │               ┌─┐            │Last│
               │several lines│               ║"│            └────┘
               └─────────────┘               └┬┘
                                             ┌┼┐
                                              │
                                             ┌┴┐


Privacy Policy      Advertise