Sequence diagrams: parallel fragments

Sequence diagrams: parallel fragments

puml.online

简介 / Introduction

When one request triggers several independent sub-flows at the same time, a sequence diagram should not draw them as a chain of sequential arrows — it should use a parallel fragment. PlantUML and Mermaid both use the par keyword, but the syntax for separating parallel branches differs between them. This article compares both using the same “query product info” scenario.

PlantUML version

1
2
3
4
5
6
7
8
9
10
11
@startuml
Alice -> Bob: query product
par inventory service
Bob -> Carol: query stock
Carol --> Bob: quantity
else pricing service
Bob -> Dave: query price
Dave --> Bob: unit price
end
Bob --> Alice: aggregated result
@enduml

Inside a PlantUML par block, parallel branches are separated with else (same convention as alt), and the text on each par/else line becomes that branch’s label. The block is closed by end, after which the flow returns to the main sequence.

Mermaid version

1
2
3
4
5
6
7
8
9
10
sequenceDiagram
Alice->>Bob: query product
par inventory service
Bob->>Carol: query stock
Carol-->>Bob: quantity
and pricing service
Bob->>Dave: query price
Dave-->>Bob: unit price
end
Bob-->>Alice: aggregated result

Inside a Mermaid par block, parallel branches are separated with and: the first branch follows par directly, and every later branch starts with and. Mermaid does not accept else inside par — writing it raises a Parse error.

对比 / Side-by-side

Feature PlantUML Mermaid
Parallel block keyword par … end par … end
Branch separator else and
Branch label par label / else label on the same line par label / and label on the same line
Label required No No (but unlabeled branches are hard to read)
else inside par ✅ correct ❌ parse error
and inside par ❌ syntax error ✅ correct
Nested parallel blocks ✅ supported ✅ supported

小结 / Wrap-up

Both engines express parallelism with par and share the same overall skeleton, but their branch separators are inverted: PlantUML uses else, Mermaid uses and. Checking the target engine before writing avoids a failed render. When the same sequence logic is maintained across both engines, a good team convention is to keep the branch labels identical between the two versions, so migration only requires swapping the separator keyword.

  • Title: Sequence diagrams: parallel fragments
  • Author: puml.online
  • Created at : 2026-11-07 09:00:00
  • Updated at : 2026-11-26 01:07:01
  • Link: https://puml.online/blog/sequence-diagram-parallel-fragment-en/
  • License: This work is licensed under CC BY-NC-SA 4.0.