Sequence diagrams: grouping with divider/box

Sequence diagrams: grouping with divider/box

puml.online

简介 / Introduction

When a sequence diagram has many messages it gets messy. Dividers / Groups / Boxes let you visually containerize related messages. PlantUML uses group and so does Mermaid — the syntax is nearly identical but the details differ.

PlantUML 版

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@startuml
skinparam backgroundColor #FEFEFE
skinparam groupBackgroundColor #E8F4FD
skinparam groupBorderColor #1E90FF

participant Client
participant "Auth Service" AS Auth
participant "API Gateway" AS GW

group 认证阶段
Client -> Auth : 登录请求
Auth -> Auth : 验证凭证
Auth --> Client : JWT Token
end

group 业务请求
Client -> GW : 请求 + JWT
GW -> GW : 校验 Token
GW --> Client : 业务数据
end
@enduml

Mermaid 版

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
sequenceDiagram
participant C as Client
participant A as Auth Service
participant G as API Gateway

group 认证阶段
C->>A: 登录请求
A->>A: 验证凭证
A-->>C: JWT Token
end

group 业务请求
C->>G: 请求 + JWT
G->>G: 校验 Token
G-->>C: 业务数据
end

对比 / Side-by-side

Feature PlantUML Mermaid
Keyword group <label> group <label>
End marker end end
Nesting Yes, multi-level Yes
Styling skinparam groupBackgroundColor CSS / theme override
Label Single line, right after group Same as PlantUML
Arrow style -> / --> ->> / -->>

小结 / Wrap-up

PlantUML and Mermaid share nearly identical group syntax, so the learning curve is minimal. PlantUML lets you deeply customize colors and borders via skinparam; Mermaid currently relies more on CSS themes. For quick small diagrams Mermaid wins; when you need fine-grained styling go with PlantUML.

  • Title: Sequence diagrams: grouping with divider/box
  • Author: puml.online
  • Created at : 2026-08-30 09:00:00
  • Updated at : 2026-08-30 01:06:27
  • Link: https://puml.online/blog/sequence-diagram-divider-en/
  • License: This work is licensed under CC BY-NC-SA 4.0.
On this page
Sequence diagrams: grouping with divider/box