Most people stop at plantuml file.puml — but the command line can do far more than that. This post distils the “power user” play book: batching, CI, watch, pipes, custom pre-processing.
The minimum command-line knowledge
1
plantuml [options] file-or-files
Common options:
Option
Meaning
-tsvg / -tpng / -tpdf / -tlatex
Output format
-o dir
Output directory
-I path
!include search path
-c
Standalone SVG (no shared CSS)
-DPLANTUML_CONFIG=...
Load a global skin file
-thread N / -no-thread
Concurrency (default: JVM cores)
-checkonly
Validate, do not render
-pipe
Read from stdin / write to stdout
-stdlib
Output standard library path
-language
List supported languages
1. Single-file pipe: read from stdin
1 2 3
echo"@startuml Alice -> Bob: hi @enduml" | plantuml -pipe -tsvg > out.svg
In practice: render a puml string held in memory — pair with curl to fetch remote sources or jq to parse puml blocks in JSON.
2. Render an entire directory
1
plantuml -tsvg -o rendered/ docs/diagrams/
Renders every .puml under docs/diagrams/ to rendered/.
Drawback: recurses into subdirectories, including ones you may not want.
# Or coordinate externally ls docs/diagrams/*.puml | xargs -P 4 -I{} plantuml -tsvg {} -o rendered/
Caveat: xargs -P N spawns N plantuml processes, each a JVM — 4 processes = 4 × JVM startup overhead. Using PlantUML’s built-in multi-threaded mode is more efficient.
Performance tuning
1 2
# 4 cores → 3 threads, leaving 1 for the system plantuml -tsvg -thread 3 -o rendered/ docs/diagrams/*.puml
#!/bin/bash set -e fail=0 for f in $(find docs -name '*.puml'); do if ! plantuml -checkonly "$f"; then echo"❌ $f syntax error" fail=1 fi done exit$fail
Faster than -tsvg: parse-only, no render. 100 diagrams in 1 minute in CI.
6. Incremental builds: reuse old diagrams
1 2
plantuml -tsvg -o rendered/ docs/diagrams/*.puml # PlantUML does NOT detect changes — re-renders all diagrams
DIY incremental:
1 2 3 4 5 6 7 8
#!/bin/bash # Incremental: only re-render puml whose mtime is newer than the SVG for puml in docs/diagrams/*.puml; do svg="rendered/$(basename "$puml" .puml).svg" if [ ! -f "$svg" ] || [ "$puml" -nt "$svg" ]; then plantuml -tsvg "$puml" -o rendered/ fi done
#!/bin/bash # scripts/render-puml.sh # Render docs/diagrams to public/img/diagrams # Invalidate cache only on puml changes (with !include tracking) set -e