PlantUML Activity Diagram: Branching and Loops

Create activity diagrams with if/else branching, while loops, parallel forks, and swim lanes in PlantUML. Complete syntax for modeling business workflows.

Activity Diagrams

Detailed Explanation

Activity Diagram Branching and Loops

Activity diagrams model workflows and business processes. PlantUML uses a concise text syntax for activities, decisions, and flow control.

Basic Activity

@startuml
start
:Receive request;
:Validate input;
:Process data;
:Return response;
stop
@enduml

Activities are written between colons and semicolons: :Activity name;. The start and stop keywords create the filled circle and bull's-eye terminators.

If/Else Branching

if (Is user authenticated?) then (yes)
  :Load dashboard;
else (no)
  :Redirect to login;
  :Show login form;
endif

Nested Conditions

if (Payment method?) then (credit card)
  :Charge card;
  if (Charge successful?) then (yes)
    :Confirm order;
  else (no)
    :Show error;
  endif
elseif (PayPal) then
  :Redirect to PayPal;
else (bank transfer)
  :Generate invoice;
endif

While Loops

while (More items to process?) is (yes)
  :Process next item;
  :Update progress;
endwhile (no)

Parallel Processing (Fork/Join)

fork
  :Send email notification;
fork again
  :Update database;
fork again
  :Push to message queue;
end fork

The fork/fork again/end fork block shows activities that execute concurrently. All branches must complete before the flow continues past end fork.

Swim Lanes

|Customer|
start
:Place order;
|Warehouse|
:Pick items;
:Pack shipment;
|Shipping|
:Generate label;
:Ship package;
|Customer|
:Receive delivery;
stop

Swim lanes partition activities by responsible party using pipe characters.

Use Case

Documenting business workflows for stakeholder sign-off, modeling CI/CD pipeline stages, creating approval process diagrams for compliance documentation, and designing error handling strategies for distributed systems.

Try It — PlantUML Editor

Open full tool