How to Import and Export PlantUML
Exchange any diagram with PlantUML text: turn a PlantUML file into diagrams, and a diagram into PlantUML.
Import a PlantUML file
- In the Project Explorer, select the folder the new diagrams should go into (or a diagram in that folder).
- Choose Diagram → Import → PlantUML…
- Pick the file (
.puml,.plantuml,.pu,.iuml,.wsdor.txt).
Each diagram of the file, from @startuml to @enduml, becomes a diagram, laid out automatically.
Its kind is recognised from its content, as PlantUML does. Its title names it; without one, the file does.
The import then lists anything it could not keep.
Export a diagram as PlantUML
- Select a diagram of any kind in the Project Explorer. If it is open, it is exported as shown, including unsaved changes.
- Choose Diagram → Export → PlantUML… and pick the file.
The diagram's name becomes its title. The export lists anything PlantUML has no place for.
How the diagrams map
| Diagram | PlantUML |
|---|---|
| Class | class, abstract class, interface, enum with their members (-name : Type, {static}, {abstract}) and stereotypes; relationships --|>, ..|>, -->, ..>, o--, *--, -- with multiplicities and labels |
| Sequence | actor, participant; messages -> (synchronous), ->> (asynchronous), --> (reply), create |
| State machine | state, <<choice>>, [*] (the initial state before an arrow, the final state after one), transitions with their labels |
| Activity | start, :action;, stop, if … else … endif, fork … end fork, while, repeat (see below) |
| Use case | actor, usecase, rectangle for the system, <<include>>, <<extend>>, --|> |
| Component | component, interface; ..> (dependency), ..|> (realization), -- |
| Deployment | node (<<device>>, <<executionEnvironment>>), artifact, component, nested in braces; -- (communication path), <<deploy>>, <<manifest>> |
| Every kind | Notes, with what they are attached to |
Elements nested in a system or a deployment node are written nested in its braces; imported ones are laid out inside it.
The import also reads what people often write by hand: Java-style members (String name), class A extends B,
the short forms :Actor:, (Use case), [Component] and () Interface, return in
sequence diagrams, and the older activity syntax ((*) --> "Action").
Activity diagrams
PlantUML writes an activity as structured text, where UML Wizard draws a graph. The export finds the structure in
the graph: a decision with several outgoing flows becomes if … elseif … else … endif, up to the node where
its branches meet again; a fork becomes fork … end fork; a loop becomes while (the decision at its
top) or repeat … repeat while (the decision at its end). Guards such as [guest] become the labels of
the branches. A flow that the structured text cannot express, such as a jump into the middle of another branch, is left
out and named in the notes. The import turns the structure back into decisions, merges, forks, joins and loops.
A UML decision has no text of its own, so the condition of an imported if (in stock?) then (yes) is
left out when the branch has a label ([yes]); without one, the condition becomes the guard.
What is left out
- On export: text boxes, fonts, colours and line styles, tagged values, and notes attached to relationships in the kinds of diagram where PlantUML attaches notes only to elements.
- On import: styling (
skinparam, colours,hide), combined fragments, boxes and references of sequence diagrams (their messages are kept), composite states (their states are kept beside them), history states, swimlanes and partitions (their actions are kept), packages (a class keeps its package as the tagged valuenamespace), and!include. Lines that are not understood are named in the notes.
An exported file is ordinary PlantUML: render it with PlantUML itself, keep it next to the code, or paste it into any tool that reads PlantUML.