Name conventions for @startuml <filename>

0 votes
asked Mar 16, 2025 in Question / help by albert (3,580 points)

In plantuml it is possible to have after @startuml a filename that will be the name of the image file that is generated like in

@startuml ex_1
Alice -> Bob : Hi
@enduml

where the e.g. the file ex_1.png (provide png output is requested) will be generated.

the question I have is:

  • What are the rules in respect to the filename?
  • What will happen with the other parts on the @startuml line

So far I did some tests and got:

  • not allowed characters are <, > and |
  • an extension is stripped, so ex_1.jpeg will still generate ex_1.png
  • something like 
      @startuml ex_3  ex_3a -> ex_3b : ex3c
      Alice -> Bob : Hi
      @enduml

           will result in a completely ignored diagram name and a diagram with just the Alice -> Bob part

  • something like:
      @startuml  ex_wa -> ex_wb : ex_weird
      Bob -> Alice : hello_weird
      @enduml

        will result in a diagram with both the ex_wa -> ex_wb : ex_weird and Bob -> Alice : hello_weird parts and no special filename.

2 Answers

0 votes
answered Mar 18, 2025 by dickmaley (4,160 points)
I have seen plantuml examples that had the syntax you are referring to.

To experiment I used
@startuml ex_1
Alice -> Bob : Hi
@enduml

with each of the following editors
https://www.plantuml.com/plantuml/uml/SyfFKj2rKt3CoKnELR1Io4ZDoSa700001
https://editor.plantuml.com/SoWkIImgAStDuNBAJrBGjLDmpCbCJbMmKiX8pSd9vt98pKi1IW80
https://www.planttext.com/
https://github.com/richardmaley/PlantUMLEditor

With each editor I selected export as png
and never was the image saved as ex_1.png.

How are you saving the image and what editor are you using?
commented Mar 19, 2025 by albert (3,580 points)

I use the plantuml.jar directly from the command line (and by means of a program through a system command) and the plantuml.jar writes out the image directly like in:

java -Djava.awt.headless=true -jar plantuml.jar aa.pu

which produces the file ex_1.png

0 votes
answered Mar 29, 2025 by kirchsth (7,760 points)

Hi @albert,

you can use double quotes, e.g. following source produces a file with spaces and underscores....  like below:

@startuml  "ex_wa --- ex_wb ... ex_weird"
  Bob -> Alice : hello_weird
@enduml

ex_wa --- ex_wb ... ex_weird.png

I tried it with your sample title "ex_wa -> ex_wb : ex_weird" too, but ">" and ":" are not valid file name elements and therefore not working.

BR
Helmut

...