Direction
Set the layout direction once near the top of the file.
>LR | Value | Meaning |
|---|---|
| LR | Left to right |
| TB | Top to bottom |
| RL | Right to left |
| BT | Bottom to top |
Everything in the .g format — syntax, operators, shapes, and grammar. For the canonical source, see the spec on GitHub.
One statement per line. : for shape, > for edges, @ for groups, $ for styles. Start with structure, add layout and styling only when you need it.
>LR
alarm:c Alarm
snooze:d "Snooze?"
bed:p "Back to Bed"
alarm>snooze
snooze>bed yes
snooze>alarm no
@morning "Morning" {alarm snooze bed}
You can stop much earlier than this. a>b is already a complete graph.
Set the layout direction once near the top of the file.
>LR | Value | Meaning |
|---|---|
| LR | Left to right |
| TB | Top to bottom |
| RL | Right to left |
| BT | Bottom to top |
Syntax: id[:shape] [label] [#color]
coffee
coffee:r
coffee:r Coffee
latte:r "Oat Latte" #0af
note:r """Monday mood:
need caffeine""" | Char | Shape | Typical use |
|---|---|---|
| r | Rectangle | Steps, actions, things you do |
| d | Diamond | Yes/no questions, decisions |
| c | Circle | Starting and ending points |
| o | Oval | States, situations |
| p | Pill | Labels, tags, endpoints |
| h | Hexagon | Preparation, setup steps |
Syntax: id operator id [label] [#color]
a>b
wake>coffee "need it"
plans~backup "if bored"
hunger=fridge "urgent"
salt--pepper
me<>dog "besties" Chains compress repeated edges into one line. They cannot carry labels, so use separate edge statements if you need text on each hop.
wake>coffee>work>lunch
// labeled version
wake>coffee "desperately"
coffee>work "reluctantly"
work>lunch "finally" | Operator | Style | Meaning |
|---|---|---|
| > | Solid arrow | This leads to that |
| ~ | Dashed arrow | Maybe, optional, or later |
| = | Thick arrow | The main or important path |
| -- | Line | Connected, no direction |
| <> | Bidirectional | Goes both ways |
Groups create containers. Classes let you style multiple nodes at once.
@morning "Morning" {alarm coffee commute}
.rushed{coffee commute}
$.rushed{stroke:#f44}
Comments use //. The current parser accepts both full-line and end-of-line comments. Use quotes for multi-word labels and triple quotes for multiline labels.
// weekend plans
brunch:r "Sunday Brunch" // the good kind
note:r """Step 1: Sleep in
Step 2: Pancakes""" | Layer | What it adds |
|---|---|
| Semantic | Nodes, edges, groups, class assignment |
| Layout | Direction and explicit positions |
| Style | Shape selectors, class selectors, id selectors |
Auto-layout is the default, but you can pin nodes with explicit coordinates. Style blocks are CSS-like and target shapes, classes, or IDs.
couch@120,80^220x72
fridge@420,160
$:r{fill:#111;stroke:#fff}
$.rushed{stroke:#f44}
$#couch{fill:#0af}
Position syntax is id@x,y with optional size suffix ^widthxheight.
The canonical EBNF lives in the core repo. This excerpt covers the top-level structure and the main statement forms you use most often.
graph = { line } ;
line = direction | node | edge | edge_chain | group | class_assignment | position
| style_block | comment | blank ;
direction = ">" , ( "LR" | "TB" | "RL" | "BT" ) ;
node = id , [ ":" , shape ] , [ label ] , [ color ] ;
edge = id , edge_op , id , [ label ] , [ color ] ;
edge_chain = id , edge_op , id , { edge_op , id } ;
group = "@" , id , [ label ] , "{" , { group_member } , "}" ;
class_assignment = "." , class_name , "{" , { id } , "}" ;
position = id , "@" , integer , "," , integer , [ size_suffix ] ;
style_block = "$" , selector , "{" , { property } , "}" ;
comment = "//" , { any_char } ; Open the editor for the fastest path, use the CLI in scripts, or install the packages in your app.
Built for people arriving from ChatGPT, Claude, Mermaid, or DOT. Paste, render, tweak, then export SVG or PNG.
Open editorUse the CLI in build scripts, content pipelines, or terminals where you want SVG and PNG output without opening the editor.
npm install -g @glypho/cli glypho render diagram.g -f pngglypho from mermaid flow.mmdglypho info diagram.gOne package gets you the parser and renderer for Node.js, the browser, or React.
npm install glypho
Parse .g, convert formats, render SVG strings, or mount the React component.