Activity diagrams: decision and merge nodes

Activity diagrams: decision and merge nodes

puml.online

Introduction

Activity diagrams model business processes in a system. The core elements are decision nodes (branching logic) and merge nodes (converging paths). Both are drawn as diamonds: a decision node picks a branch based on a condition, while a merge node brings multiple paths back together. This article uses the same login flow example in both PlantUML and Mermaid to compare syntax and rendering.

PlantUML

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@startuml
skinparam activity {
BackgroundColor #Fog
DiamondBackgroundColor #LightYellow
DiamondBorderColor #Orange
}
|Client|
start
:Enter username and password;
:Submit login request;
if (Credentials valid?) then (Yes)
:Show dashboard;
stop
else (No)
:Show error message;
:Back to sign-in page;
endif
stop
@enduml

PlantUML uses if (...) then (...) else (...) endif to express decision nodes; merge nodes are implied by endif. The |Client| swimlane syntax tracks the actor. Branch labels like (Yes) / (No) are written directly after then / else.

Mermaid

1
2
3
4
5
6
7
8
flowchart TD
A[Enter username and password] --> B[Submit login request]
B --> C{Credentials valid?}
C -->|Yes| D[Show dashboard]
C -->|No| E[Show error message]
E --> F[Back to sign-in page]
D --> G[End]
F --> G

Mermaid draws decision nodes with { } (diamond shape). Branch labels are placed on edges using |Yes| / |No| syntax. A merge node is simply two edges converging on the same target node — no explicit merge syntax required. Mermaid does not support swimlanes natively, but subgraph can approximate the effect.

Side by side

Feature PlantUML Mermaid
Decision node syntax if (...) then (...) else (...) endif { } diamond node
Merge node implicit via endif edges converge on same target node
Branch labels (Yes) / (No) after then/else `
Swimlanes |Actor| native support not supported, use subgraph instead
Start/end start / stop keywords plain nodes, no explicit start/end

Wrap-up

Decision and merge nodes are the basic building blocks of activity diagrams. PlantUML’s if/endif structure reads like code and scales well for deeply nested conditions. Mermaid’s { } nodes with edge labels are more visual and require less ceremony for straightforward flows. Both clearly express branching and convergence; pick based on your team’s toolchain and the diagram’s complexity.

  • Title: Activity diagrams: decision and merge nodes
  • Author: puml.online
  • Created at : 2026-09-09 09:00:00
  • Updated at : 2026-12-06 10:29:22
  • Link: https://puml.online/en/blog/activity-diagram-decision-merge/
  • License: This work is licensed under CC BY-NC-SA 4.0.
On this page
Activity diagrams: decision and merge nodes