UML Wizard logo

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

  1. In the Project Explorer, select the folder the new diagrams should go into (or a diagram in that folder).
  2. Choose Diagram → Import → PlantUML…
  3. Pick the file (.puml, .plantuml, .pu, .iuml, .wsd or .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

  1. Select a diagram of any kind in the Project Explorer. If it is open, it is exported as shown, including unsaved changes.
  2. 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

DiagramPlantUML
Classclass, abstract class, interface, enum with their members (-name : Type, {static}, {abstract}) and stereotypes; relationships --|>, ..|>, -->, ..>, o--, *--, -- with multiplicities and labels
Sequenceactor, participant; messages -> (synchronous), ->> (asynchronous), --> (reply), create
State machinestate, <<choice>>, [*] (the initial state before an arrow, the final state after one), transitions with their labels
Activitystart, :action;, stop, if … else … endif, fork … end fork, while, repeat (see below)
Use caseactor, usecase, rectangle for the system, <<include>>, <<extend>>, --|>
Componentcomponent, interface; ..> (dependency), ..|> (realization), --
Deploymentnode (<<device>>, <<executionEnvironment>>), artifact, component, nested in braces; -- (communication path), <<deploy>>, <<manifest>>
Every kindNotes, 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

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.