Skip to Content
ToDiagram

ToDiagram Format

Describe architecture, process and data model diagrams as nodes and edges in JSON.

The ToDiagram format describes a diagram as nodes and edges in JSON. Use it for architecture maps, process flows, data models and any other diagram you design yourself. Files have the extension .todiagram, and the editor's format menu lists the format as Custom.

You can write the JSON by hand, build the diagram on the canvas, or let an AI app write it through the MCP server.

Example

{
  "nodes": [
    {
      "id": "web",
      "label": "Web app",
      "iconUrl": "logos:nextjs-icon",
      "fields": { "framework": "Next.js" }
    },
    {
      "id": "api",
      "label": "Orders API",
      "iconUrl": "logos:nodejs-icon",
      "fields": { "port": 8080, "replicas": 3 }
    },
    {
      "id": "db",
      "label": "PostgreSQL",
      "iconUrl": "logos:postgresql",
      "fields": { "version": 16 }
    },
    {
      "id": "queue",
      "label": "Job queue",
      "iconUrl": "logos:rabbitmq-icon"
    }
  ],
  "edges": [
    { "from": "web", "to": "api", "label": "REST" },
    { "from": "api", "to": "db", "label": "SQL" },
    { "from": "api", "to": "queue", "label": "jobs" }
  ]
}
The document above as a diagram: a web app linked to an orders API, which is linked to PostgreSQL and a job queue, each with its logo
The document above, drawn by the editor.

Open a ToDiagram example in the editor

To start from a finished diagram instead, open a new tab in the editor and choose Templates.

JSON Schema

The JSON Schema for this format is published at https://todiagram.com/schemas/todiagram.json. Use it to validate documents you generate.

Direction

The optional direction key at the top level sets which way the diagram flows: RIGHT (the default), LEFT, DOWN or UP.

{
  "direction": "DOWN",
  "nodes": [{ "id": "a" }, { "id": "b" }],
  "edges": [{ "from": "a", "to": "b" }]
}

Swap direction in the canvas toolbar switches between RIGHT and DOWN for you.

Groups

A node with its own nodes list is a group. Its children are drawn inside it, and edges can connect nodes in different groups.

{
  "nodes": [
    {
      "id": "backend",
      "label": "Backend",
      "nodes": [
        { "id": "auth", "label": "Auth service" },
        { "id": "data", "label": "Data service" }
      ]
    },
    { "id": "db", "label": "PostgreSQL", "shape": "cylinder" }
  ],
  "edges": [
    { "from": "auth", "to": "db" },
    { "from": "data", "to": "db" }
  ]
}

Node ids must be unique in the whole document, including inside groups.

Custom Theming

Add a custom_theme field to a node to set its colors. It takes the same properties as a theme file, and it wins over the theme chosen in the editor. See Theme Properties for the names.

{
  "id": "api-gateway",
  "label": "API Gateway",
  "custom_theme": {
    "NODE": {
      "NODE": "#1e293b"
    },
    "EDGE": {
      "EDGE": "#38bdf8",
      "LABEL": "#fff"
    },
    "TEXT": {
      "TEXT": "#fff"
    }
  }
}

Icons

iconUrl takes an image URL or the name of an Iconify icon. A name has the form set:icon-name, for example lucide:database or logos:postgresql. A name that does not exist is not drawn.

The icon sits in a tile beside the node's label. An icon of one color is drawn in white on the node's color. A logo, an emoji or a photo keeps its own colors, on a neutral tile.

imageUrl is the older name for the same thing and still works. When a node has both, iconUrl is used.

{
  "id": "db",
  "label": "Database",
  "iconUrl": "logos:postgresql"
}

Description

description puts one short line under a node's label, inside its header. Use it for what the node does or why it is there; the rows below stay for data.

{
  "id": "barista",
  "label": "Barista",
  "iconUrl": "noto:woman-cook",
  "description": "Grinds fresh for every cup",
  "fields": { "cups_a_day": 180 }
}

Groups and nodes with a non-rectangular shape don't show it. For anything longer than a few lines, use details.

Not everything belongs on the card. Two node keys hold data that is shown on demand instead:

  • link: the node's primary destination (an http, https or mailto URL).
  • details: content for the details panel, a markdown description and a list of related links.
{
  "id": "editor_mvp",
  "label": "Editor MVP",
  "iconUrl": "fa7-solid:pen-to-square",
  "fields": { "owner": "Frontend", "status": "in progress" },
  "link": "https://example.com/projects/editor-mvp",
  "details": {
    "description": "Ships the **canvas editor**.\n\n- [x] node modal\n- [ ] inline edit",
    "links": [
      { "label": "Design doc", "url": "https://example.com/docs/editor" },
      { "label": "Figma", "url": "https://example.com/figma/editor" }
    ]
  }
}

What a click does depends on the node and on where the diagram is viewed:

Node hasViewersEditor
detailsClick opens the details panelClick opens the details panel, where you can edit it
link onlyClick opens the linkClick opens the details panel; Cmd/Ctrl+click opens the link
bothDetails panel, with "Open link" as its primary actionSame as details; Cmd/Ctrl+click opens the link
neitherNothing beyond selectingClick opens the details panel, so you can add them

Notes:

  • Only http, https and mailto URLs are opened; anything else is ignored.
  • The description is rendered as Markdown (GitHub flavored: lists, tables, task lists). Raw HTML is not rendered.
  • Unknown keys inside details are preserved by the editor and ignored by the renderer, so you can keep your own data there.
  • In the editor, the details panel is the node editor. Click the pencil, then click any part of it to edit in place: icon, title, id, summary (the node's description), the details description, links, fields, shape and colors. Each change is applied to the document as you make it. Double-click a node to jump straight to renaming it. Double-clicking empty canvas adds a node and opens it there. See Edit on the Diagram.
  • Edges accept the same link and details keys. They are reserved today and validated by the schema, but the editor does not show them yet.

Structure

Nodes

Every node must have an id field. Use the fields object to add key-value pairs that are displayed as rows on the node card.

Prop

Type

Fields Example:

{
  "id": "server",
  "label": "API Server",
  "iconUrl": "lucide:server",
  "fields": {
    "port": 3000,
    "status": "active",
    "uptime": 99.9,
    "ssl": true
  }
}

Deprecated: top-level extra properties

Top-level extra properties on a node are deprecated and may be removed in a future version. Always use the fields object for key-value display data.

Shapes

Set the shape field on a node to change its outline. The default is a rounded rectangle.

Shapes other than rectangles don't show fields, because there is no room inside them. An iconUrl stacks above the label, both centered inside the shape.

ValueDescription
rectangleSharp-cornered rectangle
roundedRounded rectangle (default for nodes without shape)
stadiumPill / capsule
subroutineRectangle with two inner vertical bars
cylinderDatabase / storage symbol
circleCircle
double-circleCircle with an inner ring (terminal / accept state)
diamondDecision / branch
hexagonHexagon
parallelogramRight-leaning parallelogram
parallelogram-altLeft-leaning parallelogram
trapezoidWide-bottom trapezoid
trapezoid-altWide-top trapezoid
asymmetricRectangle with a left-edge notch

Example:

{
  "nodes": [
    { "id": "start",   "label": "Start",       "shape": "stadium" },
    { "id": "decide",  "label": "Approved?",   "shape": "diamond" },
    { "id": "store",   "label": "PostgreSQL",  "shape": "cylinder" },
    { "id": "end",     "label": "Done",        "shape": "double-circle" }
  ],
  "edges": [
    { "from": "start",  "to": "decide" },
    { "from": "decide", "to": "store",  "label": "yes" },
    { "from": "store",  "to": "end" }
  ]
}

Edges

Edges define connections between nodes.

Prop

Type


Configuration

You can include an optional configuration object at the root level to customize field mappings. This is useful when your data has field names that conflict with the defaults (e.g., a column named id or label).

Schema Field Mappings

The configuration.schema object lets you override which fields are used for node IDs, labels, edges, etc.

{
  "configuration": {
    "schema": {
      "keys": {
        "nodes": "nodes",
        "edges": "edges",
        "direction": "direction"
      },
      "node": {
        "id": "id",
        "label": "label",
        "imageUrl": "imageUrl",
        "iconUrl": "iconUrl",
        "shape": "shape",
        "customTheme": "custom_theme",
        "link": "link",
        "details": "details",
        "description": "description"
      },
      "edge": {
        "from": "from",
        "to": "to",
        "label": "label"
      }
    }
  },
  "nodes": [...],
  "edges": [...]
}

Example: Custom ID Field

If your data uses name as the unique identifier instead of id:

{
  "configuration": {
    "schema": {
      "node": { "id": "name" }
    }
  },
  "nodes": [
    { "name": "server-1", "fields": { "status": "running" } },
    { "name": "server-2", "fields": { "status": "stopped" } }
  ],
  "edges": [
    { "from": "server-1", "to": "server-2" }
  ]
}

Example: Database Schema Diagram

Column names like id or label can be used freely inside the fields object without conflicting with reserved node keys:

{
  "nodes": [
    {
      "id": "users",
      "label": "users",
      "iconUrl": "logos:postgresql",
      "fields": {
        "id": "🔑 uuid",
        "email": "varchar *",
        "name": "varchar"
      }
    },
    {
      "id": "posts",
      "label": "posts",
      "iconUrl": "logos:postgresql",
      "fields": {
        "id": "🔑 uuid",
        "user_id": "🔗 uuid",
        "title": "varchar *"
      }
    }
  ],
  "edges": [
    { "from": "posts", "to": "users", "label": "user_id" }
  ]
}

On this page