Draw UML activity diagrams

draw.io 23 Nov 2022

Share:

UML activity diagrams show the sequence of actions and the flow of control in a system or a process. You can model the behaviour of physical and digital systems, as well as business process flows with activity diagrams.
UML activity diagrams are used to model the flow of control and sequence of actions in a process or system
UML activity diagram template in draw.io

What’s the difference between activity and sequence diagrams?

Sequence diagrams show the message flow between objects. They show a timeline of the sequence of messages passed and received.

Activity diagrams show the flow of control in a process - the order of execution of actions to complete that activity.

They are similar to basic flowcharts and are easy to draw and read.

Enable the UML shape libraries

Go to our online version of draw.io or open the draw.io desktop app or any of our integrations to create a new activity diagram.

Shapes for activity diagrams are in the General shape library and its Advanced sub-library (enabled by default), and the UML 2.5 shape library. The older UML shape library also contains some useful shapes.

  1. Click on More Shapes at the bottom of the left panel.
  2. Enable the UML 2.5 and UML shape libraries in the Software section.
  3. Click Apply to return to the diagram editor.
    Enable the UML 2.5 shape library, and the older UML library if you wish to use those shapes

Use an activity diagram template

  1. Select Arrange > Insert > Template from the menu.
  2. Select the UML category, then select an activity diagram template.
  3. Click Insert to add the template to the drawing canvas.
    Insert an UML activity diagram template in draw.io from the template library

UML activity diagram symbols

The shapes used to draw activity diagrams are similar to those use to draw simple flowcharts.

The shapes used in UML activity diagrams are in the General and UML 2.5 shape libraries
Shapes used in UML activity diagrams - open this reference in our diagram viewer

  • Start: solid circle.

  • End: solid circle inside another circle.

  • Swimlanes: container shapes with multiple collapsible lanes, vertical or horizontal, from the Advanced shape library. These are called partitions in the UML standard.

    • Drop a shape into a swimlane when the outline is purple to add it to the lane. If you move that swimlane to another position or resize it, the shapes it contains will move with it.
      Drag a shape from the shape library and drop it into a swimlane when the outline of the lane turns purple
    • Hold down Alt or Option as you drop to overlap the shape without adding it to the lane.
    • Finally, drag connectors between the shapes - you can connect to shapes in other lanes.

  • Action: rectangle with rounded corners, may link to detailed sub-activity diagrams on another page within the same diagram.
    Indicate on the shape label when an action is a <<sub-activity>> and link to its diagram on another page

  • Object: rectangle with square corners, to hand an object to another action.

  • Note: comment shape - a rectangle with a folded corner.

  • Interruptible activity region: large rectangle with rounded corners and a dashed outline. This region surrounds actions that are allowed or able to be interrupted. Move this shape to the back via the Arrange tab in the format panel.

Flow connectors in activity diagrams

  • Control flow: solid connector arrow.

  • Object flow: (optional) dashed connector arrow.

  • Fork: solid thin rectangle with one connector coming in and two or more connectors going out.

  • Join or synchronise: solid thin rectangle with one or more connectors coming in and a single connector going out.

  • Merge: diamond with multiple connectors coming in and a single connector going out. May be used instead of the join shape.

  • Interrupt flow: a zig-zag connector coming out of the interruptible activity region. Alternatively, use the straight connector with an interrupting zig-zag shape from the UML 2.5 shape library.
    A straight connector with a zig-zag label can also be used as an interrupt in UML activity diagrams

Conditions and decisions

  • Decision: diamond with one or more connectors coming out. These may be labelled with the [decision] or [condition] that must be true for the flow to proceed.

  • Guard statement: rectangle with the condition preceded by a colon. Alternatively, write the colon before the action name and the condition in square brackets on the connector.
    When a flow has a condition, the guard colon can be placed in the label of the action shape in an activity diagram

The following activity diagram example details the action steps and flow of control to process a customer’s order.

Activity diagrams are used to model workflows in various ways
Activity diagram for processing a customer’s order - open this in our diagram viewe

Advanced activity diagram symbols

Two small circles with matching letters may be used to continue a flow over a long distance to avoid overlapping connectors or clutter in your activity diagram.
Surround your activity diagram with the UML Diagram shape and a label that contains the type of diagram (act), the activity name, followed by any parameters in curly brackets

Signals

Use a flag shape from the the UML 2.5 shape library to indicate an interrupt signal or condition and place it inside the interruptible region.
Use a signal shape to label the interruptible region's interrupt condition in an activity diagram

You can also use outgoing or incoming (flag) signal shapes to show that notifications are passed to or received by other actions.
Signals passed to other actions in an activity diagram - in this case automated notifications from the postal system when an order is sent and delivered

Parameters

Surround your entire activity diagram with the Diagram shape from the UML 2.5 shape library. Alternatively, use a large rectangle with rounded corners.

Write act in the top left to indicate it is an activity diagram, followed by the activity name, and the activity parameters or preconditions in curly brackets. Parameter types are optional.
Surround your activity diagram with the UML Diagram shape and a label that contains the type of diagram (act), the activity name, followed by any parameters in curly brackets

Use an object shape to indicate action parameters. Types are optional, indicated with :type after the parameter’s name.
Surround your activity diagram with the UML Diagram shape and a label that contains the type of diagram (act), the activity name, followed by any parameters in curly brackets

Additional information

Show constraints and specific details in action, object and swimlane labels.

  • <<precondition>> and <<postcondition>> for constraints on behaviour-driven actions.
  • <<singleExecution>> for actions that execute only once in a repeating loop of actions.
  • <<external>> for actors who are outside the organisation.
  • <<attribute>> to indicate actor hierarchy in swimlanes.

If you aren’t using swimlanes, include the actor in the shape label using brackets. For example: <<external>> (Customer) Submit order

More about UML diagrams

UML is a diagramming standard with many different types of diagrams used to model the behaviour of a system, its data flow, states, and structure.

Diagram types defined in UML 2.5

Learn more about the following UML diagram types and how to create them in draw.io.

Tip: draw.io can also automatically create activity diagrams from text using the Mermaid syntax and PlantUML.

Follow us on GitHub, Twitter, Facebook.

Share: