# Draggable template format > Draggable (https://draggable.co.uk) is a free, in-browser diagram and flowchart tool. A diagram is a "template": a small piece of XML (or JSON) listing boxes and the connections between them. This page tells an AI assistant, or any other program, how to write one. You only need to describe WHAT is in the diagram: the steps, and what connects to what. Leave out positions, sizes and colours, and Draggable lays the diagram out, sizes each box to its text, colours it, and routes the lines. This is called simple mode, and it is the form you should write unless asked otherwise. ## How the person uses what you write Give the template in one code block. The person then, in Draggable: 1. chooses File → "Paste template / use with AI", 2. pastes your text and presses Import. They can also paste it straight onto the canvas, or save it as a .txt file and use Import. Text around the template (a greeting, Markdown code fences) is ignored, so no special care is needed. If something is wrong, Draggable lists the problems in plain words; the person can paste that list back to you. ## Simple mode: the form to write ```xml ``` Rules: - Give every box a short, unique `id` (letters, digits, `-`, `_`). Connections refer to boxes by id. A connection that names an id that does not exist is skipped and reported. - Put the box's wording between the tags. Keep it short: a few words, at most a sentence. Use `&` `<` `>` for `&` `<` `>` (a bare `&` is repaired for you). - Do NOT write `x`, `y`, `width`, `height` or colours in simple mode. If any box has no `x`/`y`, every box is positioned automatically and any coordinates you did give are ignored. - List boxes in the order the flow reads, main path first. Order is used to break ties in the layout. - For a decision, write the expected ("yes" / happy) branch first. Label each branch with `label`. - A line back to an earlier step (a retry loop) is fine; it is drawn around the outside. - Write one `` per arrow. Do not draw the same arrow twice. ### Template attributes | Attribute | Meaning | |------------|---------| | `name` | Name in the template list. Required in practice. An existing template of the same name is never overwritten; the import is numbered instead. | | `title` | Optional heading drawn above the diagram. | | `subtitle` | Optional line under the heading. | | `layout` | `down` (default): the flow runs top to bottom. `right`: left to right. Ignored when lanes are used (lanes always run left to right). | ### Box attributes (simple mode) | Attribute | Meaning | |-----------|---------| | `id` | Unique id, used by connections. | | `shape` | What kind of step it is. See the list below. Default `process`. | | `lane` | Name of the swimlane the box belongs to. See Swimlanes. | | `color` | Optional fill, any CSS colour (`#fde68a`, `rgb(…)`). Leave out for the standard colours. | | `textColor`, `bold="true"`, `fontSize` | Optional text styling. | | `borderColor`, `borderWidth`, `borderDash="true"` | Optional outline. | | `width`, `height` | Optional size in pixels. Leave out and the box fits its text. | ### Shapes Use the name on the left; the alternatives in brackets are accepted too. | `shape` | Use for | |------------|---------| | `process` | A step or action (also: `rect`, `step`, `task`) | | `start` | Where the flow begins (also: `terminator`, `pill`) | | `end` | Where the flow finishes; drawn green (also: `stop`) | | `decision` | A yes/no question or branch (also: `diamond`, `condition`) | | `input` | Data going in or out (also: `output`, `io`, `para`) | | `database` | A data store (also: `db`, `cylinder`, `cyl`) | | `document` | A document, email or report (also: `doc`, `file`) | | `subprocess` | A step that is itself a whole process (also: `sub`) | | `preparation` | A set-up step (also: `hexagon`, `hex`) | | `manual` | Something typed in by a person | | `trap` | A manual operation | | `delay` | A wait (also: `wait`, `timer`) | | `offpage` | A link to another diagram | | `note` | A comment (also: `comment`, `annotation`) | | `cloud` | An external system or service (also: `external`, `api`) | | `ellipse` | A state, or a connector point (also: `circle`) | | `triangle`, `arrow` | Plain shapes | | `text` | Words with no box (also: `label`) | An unknown shape is drawn as `process` and reported. ### Connection attributes | Attribute | Meaning | |-----------|---------| | `from`, `to` | Ids of the two boxes. The arrow points at `to`. Required. | | `label` | Text on the line, e.g. `Yes`, `No`, `timeout`. Up to 80 characters; keep it to a few words. | | `dash="true"` | Dashed line. Use for data, messages, or anything that is not the main flow. | | `color` | Line colour, any CSS colour. A common convention: `#dc2626` (red) for failure paths. | | `arrow="false"` | No arrowhead (a plain association). | | `arrowStart="true"` | Arrowhead at the start as well (two-way). | | `style` | `elbow` (right angles, the simple-mode default), `straight`, or `curve`. | | `fromSide`, `toSide` | Pin an end to a side of its box: `T`, `R`, `B` or `L`. Leave out unless you need to; the automatic choice is usually right. | | `width` | Thickness in pixels, 1–8. Default 2. | | `labelAt` | Where the label sits along the line, 0.05 (start) to 0.95 (end). Default 0.5. | ### Swimlanes To show who does each step, give boxes a `lane`. Draggable draws one horizontal lane per name, with a coloured heading, and the flow runs left to right across them. ```xml ``` - `` elements are optional. They set the order of the lanes (top to bottom) and, with `color="#…"`, a lane's colour. Without them, lanes appear in the order they are first used. - If you use lanes, give every box a lane. A box without one is put in the first lane and reported. - Do not create boxes for the lanes themselves; they are drawn for you. ### Writing a good diagram - 5 to 25 boxes reads well. Split anything bigger into several templates. - One `start`. Every path should reach an `end`. - Every `decision` needs at least two labelled connections leaving it. - Prefer verbs for steps ("Check stock") and questions for decisions ("In stock?"). - Do not add a legend, title box or lane boxes by hand; use `title`, `subtitle` and `lane`. ## The same thing as JSON If JSON is easier to produce, this is equivalent. Field names match the XML attributes; `text` holds a box's wording. ```json { "name": "Leave request", "title": "Leave request", "layout": "down", "lanes": ["Employee", "Manager"], "boxes": [ { "id": "start", "shape": "start", "lane": "Employee", "text": "Requests leave" }, { "id": "review", "lane": "Manager", "text": "Reviews the request" }, { "id": "ok", "shape": "decision", "lane": "Manager", "text": "Approved?" }, { "id": "done", "shape": "end", "lane": "Employee", "text": "Leave booked" } ], "connections": [ { "from": "start", "to": "review" }, { "from": "review", "to": "ok" }, { "from": "ok", "to": "done", "label": "Yes" }, { "from": "ok", "to": "start", "label": "No" } ] } ``` `lanes` and `connections` are optional; `boxes` is required. A JSON Schema is at https://draggable.co.uk/template.schema.json. ## Exact mode: full control When EVERY box has `x` and `y` (and the template has no `layout` attribute), nothing is rearranged or restyled: the diagram is drawn exactly as written. This is what Draggable's own Export produces, and what "Copy this diagram as text" gives you when a person asks you to change an existing diagram. Edit that text and return all of it. ```xml ``` Extra box attributes in exact mode: | Attribute | Meaning | |-----------|---------| | `x`, `y` | Top-left corner in pixels. Negative values are fine. x grows right, y grows down. | | `width`, `height` | Size in pixels. Default 200 × 200 if left out. | | `zIndex` | Stacking order; higher is in front. | | `alignH` (`left`/`center`/`right`), `alignV` (`top`/`middle`/`bottom`) | Text position in the box. | | `locked="true"` | Background box: cannot be clicked or dragged, and lines pass over it. Used for lanes and frames. | | `background="true"` | A background box the person has unlocked to edit. Draggable offers to re-lock it. Treat it like `locked` when reading; write `locked="true"` instead when creating. | | `container="true"` | A frame that carries the boxes inside it when dragged. | | `shape` | Use the short keys here: `rect`, `pill`, `diamond`, `para`, `hex`, `ellipse`, `cyl`, `doc`, `sub`, `manual`, `trap`, `delay`, `offpage`, `note`, `cloud`, `triangle`, `arrow`, `text`. The friendly names also work. | The template may set a default line colour with `lineColor="#188038"` on `