DSL Reference
Grammar for the flow, git, sequence, and block pseudo-code languages.
Trazo turns a few lines of line-based pseudo-code into a deterministic SVG diagram. There are four languages: a flow DSL (flowcharts), a git DSL (commit-history graphs), a sequence DSL (sequence diagrams), and a block DSL (block-grid wireframes).
Universal rules
- One statement per line. Order matters — it drives deterministic layout.
#starts a comment — everything after it on the line is ignored.- Blank lines are ignored.
- The first non-comment line chooses the language:
- starts with
flow/flowchart→ flow DSL - starts with
commit/branch/checkout/merge→ git DSL - starts with
sequence/participant/ aA ->> Bmessage → sequence DSL - starts with
block/columns→ block DSL
- starts with
- Deterministic: the same source always produces the same diagram.
Flow DSL
A forgiving subset of Mermaid's flowchart syntax.
Direction line
flow TD # top-down (default)
flow LR # left-rightNodes
| Syntax | Shape | Example |
|---|---|---|
id["label"] or id[label] | box | A[Process] |
id(["label"]) or id("label") | stadium (pill) | A(["Start"]) |
id{"label"} or id{label} | diamond | A{Decision?} |
id[("label")] | cylinder | A[("Database")] |
Append :role to color the node:
A["Request"]:primary
B["Cache hit"]:success
C["Error"]:error
D["Queued"]:warning
E["Streamed"]:streamedMulti-line labels. A literal \n or a <br> inside a label becomes a line break. The box grows taller to fit the lines and sizes to its widest line:
A["Build step\nruns at deploy"]
B["one<br>two<br>three"]Edges
| Syntax | Style |
|---|---|
A --> B | directed arrow, neutral (arrowhead at B) |
A ==> B | directed arrow, colored (source role) |
A --- B | undirected — a plain line, no arrowhead |
A === B | undirected, colored |
A <--> B | bidirectional — an arrowhead at both ends |
A <==> B | bidirectional, colored |
A -->|label| B | labeled edge (works with every arrow above) |
Every flow edge is directed by default (-->/==> draw an arrowhead at the target). Use --- when you want a plain connector with no head, and <--> for a two-way relation.
flow LR
A["Request"] --> B["Handler"] # arrow: A ▸ B
C["Cache"] --- D["Store"] # no arrow: plain association
E["Client"] <--> F["Server"] # arrows both ends: two-way syncThe same three forms with a label:
flow LR
A -->|"calls"| B # labeled directed
C ---|"relates to"| D # labeled, no arrow
E <-->|"syncs"| F # labeled bidirectionalSubgraphs
Wrap a set of nodes in a labeled container box. Nodes declared between subgraph and end join the group and are kept spatially together:
flow TD
subgraph Build ["Build time"]
A["Compile"] --> B["Bundle"]
end
subgraph Request ["Request time"]
C["Render"] --> D["Stream"]
end
B --> CSubgraphs are single-level (no nesting). A node belongs to at most one group — the first subgraph that declares it wins.
Example
flow TD
A(["Request arrives"]):primary ==> B["getCart()"]
B --> C{Cache?}
C -->|hit| D["Cache hit"]:success
C -->|miss| E["DB query"]:warning
D ==> F(["Response"]):success
E ==> FGit DSL
Describes a commit DAG using four statements.
Statements
| Statement | Description |
|---|---|
commit [id] [(author)] [: message] | Add a commit on the current branch |
branch <name> | Create and switch to a new branch |
checkout <name> | Switch to an existing branch |
merge <name> [: message] | Merge name into the current branch |
- If id looks like 6+ hex digits, it also doubles as the commit hash shown in the label.
- Author is optional, in parentheses:
commit (Alice) : Fix bug. - Message is optional, after
:. - Commits without a message render as bare markers (no label badge).
Example
commit a1b2c3 (JOYCO) : Initial commit
branch feat/checkout
commit (Elvira) : checkout: scaffold
commit (Elvira) : checkout: wire payment
checkout main
commit (JOYCO) : hotfix
merge feat/checkout : merge checkout featureLayout options (playground toggles)
| Option | Values | Default |
|---|---|---|
| Orientation | vertical / horizontal | vertical |
| Label side | right / left (or below / above in horiz.) | right |
| Edge style | elbow45 / orthogonal | elbow45 |
Tip — horizontal mode and label width. In horizontal orientation, each commit's label badge is centered above the commit dot. Long messages push adjacent commits further apart to prevent overlap — the diagram widens automatically but can become very wide with verbose messages. Keep horizontal-mode labels short: a branch name or a 2–3 word subject. Save full messages for vertical orientation where labels sit to the side and don't affect the horizontal spacing.
Sequence DSL
Sequence diagrams: participants with vertical lifelines and ordered messages between them.
Participants
participant C ["Client"]:primary
participant S ["Server"]participant declares an actor with an optional ["label"] and :role. Participants are also auto-created the first time they appear in a message, in first-seen order (which sets their column order).
Messages
| Syntax | Meaning |
|---|---|
A ->> B : label | synchronous message (solid arrow) |
A -->> B : label | asynchronous message (dashed arrow) |
A ->> A : label | self-message (a small loop on one lifeline) |
Notes
Note over A,B : both participants are busyA note draws a box spanning from the first to the last participant it covers. Note text may use \n / <br> for line breaks. Notes fall in their timeline row — interleaved between messages by source order, not stacked in a side column.
Example
sequence
participant C ["Client"]:primary
participant S ["Server"]
C ->> S : GET /cart
Note over S : reads from cache
S -->> C : 200 OK (streamed)
C ->> C : hydrateBlock DSL
A 2-D wireframe grid of boxes (no edges) — Mermaid's block-beta. Cells flow left→right and wrap to the next row; a cell can span multiple columns.
block
columns 2
Nav["Navigation"] :2
Side["Sidebar"]
Main["Content"]| Syntax | Meaning |
|---|---|
columns N | set the grid width (number of columns) |
A["label"] | a span-1 cell (shapes + :role work as in flow) |
A["label"] :2 | a cell spanning 2 columns |
A trailing bare number (:2) is the column span; a known role name (:success) is the color. Both may be combined.