PlantUML is one of the most popular tools for creating diagrams using plain text code. If you've ever needed to turn a process, workflow, or decision logic into a visual flowchart without dragging and dropping shapes in a GUI tool PlantUML gives you that ability right inside your text editor. Learning how to write flowchart code in PlantUML means you can version-control your diagrams, collaborate with teammates through code reviews, and generate visuals in seconds from simple markup.

What is PlantUML and why do people use it for flowcharts?

PlantUML is an open-source tool that lets you create diagrams from a text-based language. Instead of manually drawing boxes and arrows, you write short lines of code that describe the structure of your diagram. PlantUML then renders that code into a clean, readable flowchart image.

Developers, technical writers, and product teams use PlantUML flowcharts because the diagrams live alongside the code. When a process changes, you edit a few lines of text rather than redrawing the whole thing. This makes it especially useful for documenting software logic, onboarding workflows, decision trees, and approval processes.

If you're comparing different text-based diagram tools, our comparison of flowchart syntax options shows how PlantUML stacks up against alternatives like Mermaid and Graphviz.

How do you write a basic flowchart in PlantUML?

A basic PlantUML flowchart starts with the @startuml tag and ends with @enduml. Between those tags, you define shapes and connect them with arrows. Here's a simple example:

@startuml
start
:Receive order;
:Check stock;
if (Item in stock?) then (yes)
  :Process payment;
  :Ship item;
else (no)
  :Notify customer;
  :Cancel order;
endif
stop
@enduml

This produces a flowchart with rectangular process steps, a diamond-shaped decision, and clear branching paths. The start and stop keywords create the terminal shapes (rounded rectangles), while regular text wrapped in colons creates process boxes.

What shapes and syntax does PlantUML support for flowcharts?

PlantUML uses specific syntax to create different flowchart shapes:

  • Rectangles – Write :Text here; for standard process boxes
  • Decisions (diamonds) – Use if (condition?) then (yes) else (no) endif
  • Terminals (rounded rectangles) – Use start and stop
  • Arrows – Connect steps with --> or -> for directional flow
  • Labels on arrows – Add text after arrow notation: :label text;
  • Parallelograms – Use /:Input/output; for input/output shapes
  • Hexagons – Use :>Preparation; for preparation steps

For a full list of shape syntax and markup shortcuts, check our flowchart markup cheat sheet.

How do you add branches and loops in PlantUML flowcharts?

Creating branches with if/else

Branches in PlantUML use an if/then/else/endif block. You can nest multiple decisions inside each other for complex logic. Here's a nested example:

if (Is user logged in?) then (yes)
  if (Has permission?) then (yes)
    :Show dashboard;
  else (no)
    :Show access denied;
  endif
else (no)
  :Redirect to login;
endif

Adding loops with repeat and while

PlantUML supports two loop structures:

  • repeat ... repeat while – Runs the block at least once before checking the condition (do-while loop)
  • while ... endwhile – Checks the condition before entering the block (while loop)

Example of a repeat loop:

repeat
  :Fetch data from API;
  :Parse response;
repeat while (More pages?) is (yes)
->no;
:Process all results;

Using the switch statement

For multiple branches based on a single value, use switch:

switch (User role?)
case (Admin)
  :Full access;
case (Editor)
  :Edit content;
case (Viewer)
  :Read only;
endswitch

How do you customize the look of your PlantUML flowchart?

PlantUML lets you change colors, fonts, and styles using skinparam and inline styling:

  • skinparam – Set global styles like skinparam backgroundColor #FEFEFE or skinparam ActivityBackgroundColor #E8F5E9
  • Inline color – Add color to individual elements: :Step; #LightGreen
  • Stereotypes – Use <<highlight>> tags to apply reusable styles
  • Arrows – Customize with -[#FF0000,dashed]-> for colored dashed arrows

Example of a styled step:

:Process order; #LightBlue

This colors the "Process order" box light blue. You can chain style attributes to control line color and arrow direction at the same time.

What are common mistakes when writing PlantUML flowcharts?

  1. Missing semicolons – Every action step needs a semicolon after the closing colon. Forgetting it causes rendering errors.
  2. Not closing if/endif blocks – Every if must have a matching endif. Nesting makes this easy to miss.
  3. Using wrong arrow syntax – PlantUML activity diagrams use --> for connections, not -> (though both can work in some contexts). Stick with --> for clarity.
  4. Forgetting @enduml – Without the closing tag, PlantUML won't render the diagram.
  5. Overcomplicating a single diagram – If your flowchart has more than 20–25 steps, consider breaking it into linked sub-diagrams.
  6. Ignoring direction hints – Without directional markers, PlantUML may lay out your flowchart in unexpected directions. Use left to right direction at the top if you prefer horizontal flow.

How do you render and export PlantUML flowcharts?

Once you've written your code, you need a way to see the diagram. Here are the most common options:

  • Online editor – Paste your code into the official PlantUML server to get an instant preview
  • VS Code extension – The "PlantUML" extension by jebbs shows a live preview side-by-side with your code
  • IntelliJ plugin – JetBrains IDEs have built-in PlantUML support
  • Command line – Download the PlantUML JAR file and run java -jar plantuml.jar diagram.puml to generate PNG or SVG output

PlantUML can export to PNG, SVG, and even ASCII art, depending on your needs.

Quick-reference example: a complete PlantUML flowchart

Here's a practical flowchart for a user registration process:

@startuml
title User Registration Flow
start
:User visits sign-up page;
:Fills in registration form;
:Submit form;
if (Valid data?) then (yes)
  :Create account in database;
  :Send confirmation email;
  if (Email verified?) then (yes)
    :Activate account;
    :Redirect to dashboard;
  else (no)
    :Show "Check your email" message;
  endif
else (no)
  :Show validation errors;
  :Return to form;
endif
stop
@enduml

This covers terminals, processes, nested decisions, and both success and failure paths everything you'd need for a real-world workflow. For more syntax patterns and reference material, our flowchart syntax reference guide covers additional edge cases.

Quick checklist before sharing your PlantUML flowchart

  • ✔ Every @startuml has a matching @enduml
  • ✔ Every if block ends with endif
  • ✔ All action steps end with a semicolon
  • ✔ Decision labels (yes/no) are quoted and placed after the condition
  • ✔ The diagram renders without errors in the online editor before sharing
  • ✔ Title is added using the title keyword for context
  • ✔ Complex diagrams are split into manageable sections or sub-diagrams

Start by writing one small flowchart with three to five steps, render it to check for errors, then expand from there. The fastest way to learn PlantUML syntax is to modify existing examples and watch how the output changes.