modl Manual Override Diagram Language Open the editor

modl

modl (Manual Override Diagram Language) is a small, line-oriented text language for drawing node-and-arrow diagrams. Each line declares a node or an arrow. The editor redraws the diagram as you type and keeps the whole diagram, source and layout, in its URL.

Hello, world
hello -> world
Open in editor

Every listing in these docs has an Open in editor link like the one above. The link carries the example's source in its URL, so it opens the editor with that diagram loaded. Change it however you like: nothing is saved anywhere unless you press Save to HashBin.

A quick tour

A node line starts with an id, followed by optional attributes and a label:

Nodes
api square blue API server
db  diamond purple Database
Open in editor

An edge line connects ids with ->. Ids that haven't been declared yet become nodes automatically:

Edges
browser -> api -> db
Open in editor

Edges take attributes too, and # starts a comment:

Nodes, edges, attributes and comments
# A three-tier web app
browser circle teal /developer.mozilla.org Browser
api     square blue API server
db      diamond purple Database

browser -> api bold blue HTTPS   # thick blue arrow with a label
api -> db dashed SQL
Open in editor

A line with nothing but a color name sets the background:

Background color
white
sun big circle yellow Sun
earth circle blue Earth
sun -> earth dotted orange light
Open in editor

Cheat sheet

LineFormExample
Comment# anything, or after code following whitespacetry it
Backgroundcolor alone on a linetry it
Nodeid [size] [shape] [color] [url] [text…]try it
Edgea -> b [-> c …] [size] [line style] [color] [url] [text…]try it
Quoted word"…" or '…' as an id or text: taken literally, with ->, # and spaces as texttry it
AttributeValues
sizetiny small normal big bigger huge
shape (nodes)none circle square diamond triangle hex
line style (edges)solid dashed dotted bold
colorgray black white red orange yellow green teal blue purple pink brown
url/host/path (means https://host/path), https://…, http://…, www.…, mailto:…
texteverything else up to the end of the line

Attributes are optional, but the ones you use must appear in this order. A word that is out of order becomes part of the label instead (see Attributes).

Everything at once
# Comments start with #
black                                          # background color

# nodes: id [size] [shape] [color] [url] [text...]
n square red /google.com Node N
m circle blue /wikipedia.org Node M
t triangle green /example.com Triangle

# edges: a -> b (-> c ...) [size] [lineStyle] [color] [url] [text...]
n -> m solid purple /news.ycombinator.com N to M
m -> t small dotted teal /slashdot.org Dotted link
t -> n dashed orange /github.com Back edge

# nodes can be created just by mentioning them in an edge
a -> b -> c bold yellow /example.com Chain applies to each edge
Open in editor

Reading the listings

Listings are highlighted the way the editor reads them, so you can see how each word is understood:

node-id -> size shape / line style color url label text # comment invalid id ignored

Contents

  1. Source structure: lines, comments, whitespace, background
  2. Nodes: ids, defaults, labels, redefinition
  3. Edges: arrows, chains, labels, parallel edges
  4. Attributes: slot order, how words are recognized, label text
  5. Sizes, shapes, lines & colors: every reserved word
  6. Links & image nodes: URLs, clicking, pictures as nodes
  7. Sharing & positions: the URL format, layout, HashBin
  8. Gotchas: surprising behavior and workarounds
  9. Grammar reference: formal grammar, defaults, errors
  10. Example gallery: complete diagrams to start from

Using the editor