← Back to Guides
DiagramsPlantUML Diagrams in Markdown
Published on 2026-02-22

PlantUML Diagrams in Markdown

How to write PlantUML syntax inside fenced code blocks to create sequence, use-case, and class diagrams.

PlantUML is a leading component in the text-to-diagram ecosystem. While Mermaid excels on the web, PlantUML provides strict, powerful adherence to UML (Unified Modeling Language) standards.

Using MarkdownToPrettyPDF, you can write PlantUML simply by wrapping it in a plantuml language block.

1. Sequence Diagrams

Sequence diagrams are PlantUML’s most popular feature, offering extensive styling and grouping features impossible in simpler tools.

syntax
@startuml
actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C

User -> A: DoWork
activate A

A -> B: Create Request
activate B

B -> C: DoWork
activate C
C --> B: WorkDone
destroy C

B --> A: Request Created
deactivate B

A --> User: Done
deactivate A
@enduml
PlantUMLPlantUML diagram

Notes and Grouping

PlantUML allows you to attach notes alongside lines and create group boxes seamlessly:

syntax
@startuml
Alice -> Bob : Authentication Request
note right of Bob: Bob thinks about it
Bob -> Alice : Authentication Response

alt successful case
    Alice -> Bob: Logged in
else some kind of failure
    Alice -> Bob: Authentication Failure
end
@enduml
PlantUMLPlantUML diagram

2. Class Diagrams

Class diagrams represent the static structure of an application—its classes, methods, and visibility.

Visibility Modifiers

  • - private
  • # protected
  • ~ package private
  • + public

Example Class Diagram

syntax
@startuml
class Dummy {
  -field1
  #field2
  ~method1()
  +method2()
}

class Flight {
   flightNumber : Integer
   departureTime : Date
}

Flight o-- Airplane : aggregation
Flight *-- Passenger : composition
Dummy <|-- Flight : inheritance
@enduml
PlantUMLPlantUML diagram

3. Use Case Diagrams

Use case diagrams describe the interactions between actors (users or external systems) and the system itself.

syntax
@startuml
left to right direction
actor "Food Critic" as fc
rectangle Restaurant {
  usecase "Eat Food" as UC1
  usecase "Pay for Food" as UC2
  usecase "Drink" as UC3
}
fc --> UC1
fc --> UC2
fc --> UC3
@enduml
PlantUMLPlantUML diagram

Why PlantUML?

PlantUML is extraordinarily mature. It supports state, object, activity, deployment, and Gantt charts. By leveraging the plantuml syntax within Markdown, technical writers can version-control complex system architectures without managing binary image files.