PlantUML examples

Runnable PlantUML examples for sequence, class, use case, activity, and component diagrams. Open any example in the live editor, change the markup, and render it instantly in your browser.

@startuml
actor User
participant "Web App" as App
participant "Auth Service" as Auth
database "User DB" as DB

User -> App : Login request
App -> Auth : Validate credentials
Auth -> DB : Lookup user
DB --> Auth : User record
Auth --> App : Token
App --> User : Logged in
@enduml

PlantUML example of how to create a sequence diagram

Open in PlantUML playground
@startuml
class Organization {
  +String url
  +int id
}
class User {
  +String avatar
  +String email
}
class Repository {
  +String name
  +int stargazers_count
}

Organization "1" --> "*" Repository : repos
Organization "1" --> "*" User : members
Repository "*" --> "*" User : stargazers
@enduml

PlantUML example of how to create a class diagram

Open in PlantUML playground
@startuml
left to right direction
actor Customer
actor Admin

rectangle Store {
  Customer --> (Browse products)
  Customer --> (Add to cart)
  Customer --> (Checkout)
  Admin --> (Manage inventory)
  (Checkout) ..> (Process payment) : include
}
@enduml

PlantUML example of how to create a use case diagram

Open in PlantUML playground
@startuml
start
:Receive order;
if (In stock?) then (yes)
  :Charge payment;
  :Ship order;
else (no)
  :Notify customer;
endif
:Send confirmation;
stop
@enduml

PlantUML example of how to create an activity diagram

Open in PlantUML playground
@startuml
package "Frontend" {
  [Web App]
}
package "Backend" {
  [API Gateway]
  [User Service]
  [Order Service]
}
database "PostgreSQL" as DB

[Web App] --> [API Gateway] : HTTPS
[API Gateway] --> [User Service]
[API Gateway] --> [Order Service]
[User Service] --> DB
[Order Service] --> DB
@enduml

PlantUML example of how to create a component diagram

Open in PlantUML playground