Skip to content

D2 DynamicDiagram Spec

Source: d2.dynamic-diagram.json

This schema describes the DynamicDiagram spec for the D2 backend.

Properties

Properties

Field Type Description
type(required) string Type of the diagram. Must be exactly DynamicDiagram.
title string | null Optional diagram title.
elements array[Element] Top-level elements.
boundaries array[Boundary] Top-level boundaries.
relationships array[D2RelationshipSchema] Top-level relationships.
render_options D2RenderOptionsSchema D2-specific render options.
backend(required) string JSON schema backend. Must be exactly d2.
Examples
JSON source
{
  "backend": "d2",
  "type": "DynamicDiagram",
  "title": "Login Flow",
  "elements": [
    {
      "type": "Person",
      "label": "User",
      "alias": "user",
      "description": "Signs in to the application."
    },
    {
      "type": "System",
      "label": "Web App",
      "alias": "web_app",
      "description": "Main application used by customers."
    },
    {
      "type": "SystemExt",
      "label": "Identity Provider",
      "alias": "idp",
      "description": "External authentication service."
    }
  ],
  "relationships": [
    {
      "type": "REL",
      "from": "user",
      "to": "web_app",
      "label": "Opens sign-in page",
      "technology": "HTTPS"
    },
    {
      "type": "REL",
      "from": "web_app",
      "to": "idp",
      "label": "Authenticates user",
      "technology": "OIDC"
    },
    {
      "type": "REL",
      "from": "idp",
      "to": "web_app",
      "label": "Returns identity token",
      "technology": "OIDC"
    }
  ],
  "render_options": {
    "auto_number_relationships": true
  }
}
Rendered D2 source
direction: right
__title: ||md
  # Login Flow
|| {
  near: top-center
}
classes: {
  c4_person: {
    style.fill: "#f5f1ff"
    style.stroke: "#6f4bb2"
    style.font-color: "#211436"
  }
  c4_external: {
    style.fill: "#f7f7f7"
    style.stroke: "#767676"
    style.stroke-dash: "5"
  }
}
user: ||md
  ## User

  [Person]

  Signs in to the application.
|| {
  shape: c4-person
  class: ["c4_person"]
}
web_app: ||md
  ## Web App

  [Software System]

  Main application used by customers.
|| {
  shape: rectangle
}
idp: ||md
  ## Identity Provider

  [Software System]

  External authentication service.
|| {
  shape: rectangle
  class: ["c4_external"]
}
user -> web_app: "1. Opens sign-in page\n[HTTPS]"
web_app -> idp: "2. Authenticates user\n[OIDC]"
idp -> web_app: "3. Returns identity token\n[OIDC]"
Rendered image

DynamicDiagram minimal example

JSON source
{
  "backend": "d2",
  "type": "DynamicDiagram",
  "title": "Order Fulfillment Flow",
  "elements": [
    {
      "type": "Person",
      "label": "Customer",
      "alias": "customer",
      "description": "Places orders in the online store."
    },
    {
      "type": "System",
      "label": "Online Store",
      "alias": "online_store",
      "description": "Customer-facing commerce platform."
    },
    {
      "type": "SystemExt",
      "label": "Payment Gateway",
      "alias": "payment_gateway",
      "description": "External provider that authorizes card payments."
    },
    {
      "type": "SystemExt",
      "label": "Warehouse System",
      "alias": "warehouse_system",
      "description": "External warehouse platform that reserves and ships items."
    }
  ],
  "relationships": [
    {
      "type": "REL",
      "from": "customer",
      "to": "online_store",
      "label": "Places order",
      "technology": "HTTPS"
    },
    {
      "type": "REL",
      "from": "online_store",
      "to": "payment_gateway",
      "label": "Authorizes payment",
      "technology": "REST API"
    },
    {
      "type": "REL",
      "from": "payment_gateway",
      "to": "online_store",
      "label": "Returns authorization result",
      "technology": "HTTPS"
    },
    {
      "type": "REL",
      "from": "online_store",
      "to": "warehouse_system",
      "label": "Sends fulfillment request",
      "technology": "AMQP"
    },
    {
      "type": "REL",
      "from": "warehouse_system",
      "to": "online_store",
      "label": "Confirms reservation",
      "technology": "AMQP"
    }
  ],
  "render_options": {
    "layout": "dagre",
    "include_properties": true,
    "bidirectional_relationships": "single_edge",
    "sequence_diagram": true,
    "auto_number_relationships": true
  }
}
Rendered D2 source
direction: right
__title: ||md
  # Order Fulfillment Flow
|| {
  near: top-center
}
shape: sequence_diagram
classes: {
  c4_person: {
    style.fill: "#f5f1ff"
    style.stroke: "#6f4bb2"
    style.font-color: "#211436"
  }
  c4_external: {
    style.fill: "#f7f7f7"
    style.stroke: "#767676"
    style.stroke-dash: "5"
  }
}
customer: ||md
  ## Customer

  [Person]

  Places orders in the online store.
|| {
  shape: c4-person
  class: ["c4_person"]
}
online_store: ||md
  ## Online Store

  [Software System]

  Customer-facing commerce platform.
|| {
  shape: rectangle
}
payment_gateway: ||md
  ## Payment Gateway

  [Software System]

  External provider that authorizes card payments.
|| {
  shape: rectangle
  class: ["c4_external"]
}
warehouse_system: ||md
  ## Warehouse System

  [Software System]

  External warehouse platform that reserves and ships items.
|| {
  shape: rectangle
  class: ["c4_external"]
}
customer -> online_store: "1. Places order\n[HTTPS]"
online_store -> payment_gateway: "2. Authorizes payment\n[REST API]"
payment_gateway -> online_store: "3. Returns authorization result\n[HTTPS]"
online_store -> warehouse_system: "4. Sends fulfillment request\n[AMQP]"
warehouse_system -> online_store: "5. Confirms reservation\n[AMQP]"
Rendered image

DynamicDiagram advanced example

Elements

Boundaries

Relationships

Definitions

About labels and aliases

label is a display name for the element.

alias is a unique identifier used for referencing elements in relationships and layouts. If omitted, it is generated automatically.

You can also use label for referencing elements in relationships and layouts, but each label must be unique within the diagram.


D2ComponentDbExtSchema

D2 JSON schema for an external database-like component.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ComponentDbExt.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ComponentDbSchema

D2 JSON schema for a database-like component.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ComponentDb.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ComponentExtSchema

D2 JSON schema for an external component.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ComponentExt.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ComponentQueueExtSchema

D2 JSON schema for an external queue-like component.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ComponentQueueExt.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ComponentQueueSchema

D2 JSON schema for a queue-like component.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ComponentQueue.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ComponentSchema

D2 JSON schema for a component.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly Component.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ContainerDbExtSchema

D2 JSON schema for an external database-like container.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ContainerDbExt.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ContainerDbSchema

D2 JSON schema for a database-like container.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ContainerDb.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ContainerExtSchema

D2 JSON schema for an external container.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ContainerExt.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ContainerQueueExtSchema

D2 JSON schema for an external queue-like container.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ContainerQueueExt.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ContainerQueueSchema

D2 JSON schema for a queue-like container.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ContainerQueue.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2ContainerSchema

D2 JSON schema for a container.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly Container.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
technology string | null Optional technology.
tooltip string | null Optional D2 tooltip.

D2DynamicBoundarySchema

D2 JSON schema for a generic boundary in dynamic diagrams.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly Boundary.
elements array[Element] Elements may be nested arbitrarily.
boundaries array[Boundary] Boundaries may be nested arbitrarily.
relationships array[D2RelationshipSchema] Relationships declared inside the boundary.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2DynamicContainerBoundarySchema

D2 JSON schema for a container boundary in dynamic diagrams.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly ContainerBoundary.
elements array[Element] Elements may be nested arbitrarily.
boundaries array[Boundary] Boundaries may be nested arbitrarily.
relationships array[D2RelationshipSchema] Relationships declared inside the boundary.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2DynamicEnterpriseBoundarySchema

D2 JSON schema for an enterprise boundary in dynamic diagrams.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly EnterpriseBoundary.
elements array[Element] Elements may be nested arbitrarily.
boundaries array[Boundary] Boundaries may be nested arbitrarily.
relationships array[D2RelationshipSchema] Relationships declared inside the boundary.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2DynamicSystemBoundarySchema

D2 JSON schema for a system boundary in dynamic diagrams.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly SystemBoundary.
elements array[Element] Elements may be nested arbitrarily.
boundaries array[Boundary] Boundaries may be nested arbitrarily.
relationships array[D2RelationshipSchema] Relationships declared inside the boundary.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2PersonExtSchema

D2 JSON schema for an external person.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly PersonExt.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2PersonSchema

D2 JSON schema for a person.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly Person.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2RelationshipSchema

JSON schema for relationships supported by D2 C4 diagrams.

Properties

Field Type Description
type(required) RelationshipType Type of the relationship.
classes array[string] Optional D2 classes.
description string | null Additional details about the relationship.
from(required) string The source element alias (or unique label).
icon string | null Optional D2 icon URL.
label(required) string The label shown on the relationship edge.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
style D2StyleSchema Optional D2 style attributes.
technology string | null The technology used in the communication.
to(required) string The destination element alias (or unique label).
tooltip string | null Optional D2 tooltip.

RelationshipType

Relationship types supported by D2 C4 diagrams.

Items

Type Description
BI_REL A bidirectional relationship between two elements.
REL A unidirectional relationship between two elements.

D2SystemDbExtSchema

D2 JSON schema for an external database-like system.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly SystemDbExt.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2SystemDbSchema

D2 JSON schema for a database-like system.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly SystemDb.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2SystemExtSchema

D2 JSON schema for an external software system.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly SystemExt.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2SystemQueueExtSchema

D2 JSON schema for an external queue-like system.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly SystemQueueExt.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2SystemQueueSchema

D2 JSON schema for a queue-like system.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly SystemQueue.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

D2SystemSchema

D2 JSON schema for a software system.

Properties

Field Type Description
type(required) string Discriminator identifying the element type. Must be exactly System.
alias string | null Unique identifier for the element. If not provided, it is autogenerated from the label.
classes array[string] Optional D2 classes.
description string | null Optional description text.
direction enum[up | down | left | right] | null Optional D2 layout direction for a container.
icon string | null Optional D2 icon URL.
label(required) string Display name for the element.
link string | null Optional D2 link URL.
near string | null Optional D2 near reference.
properties DiagramElementPropertiesSchema Optional property table metadata.
shape string | null Optional D2 shape.
style D2StyleSchema Optional D2 style attributes.
tooltip string | null Optional D2 tooltip.

DiagramElementPropertiesSchema

JSON schema for tabular diagram element properties.

Properties

Field Type Description
header array[string] Header columns. Default: ["Property", "Value"].
properties(required) array[array[string]] List of rows (each row is a list of string values).
show_header boolean Whether to display the header row. Default: true.

D2 Render Options

D2RenderOptionsSchema

Render options for the D2 renderer.

Properties

Field Type Description
auto_number_relationships boolean Auto Number Relationships Default: false.
bidirectional_relationships enum[two_edges | single_edge] Bidirectional Relationships Default: two_edges.
direction enum[up | down | left | right] | null Direction Default: right.
fully_qualified_relationships boolean Fully Qualified Relationships Default: true.
include_properties boolean Include Properties Default: false.
include_technology boolean Include Technology Default: true.
include_type_label boolean Include Type Label Default: true.
layout enum[dagre | elk] Layout Default: dagre.
legend D2LegendSchema
sequence_diagram boolean Sequence Diagram Default: false.
theme integer | null Theme
title_near enum[top-left | top-center | top-right | center-left | center-right | bottom-left | bottom-center | bottom-right] | null Title Near Default: top-center.

D2StyleSchema

D2 style attributes used by D2 render options.

Properties

Field Type Description
animated boolean | null Animated
bold boolean | null Bold
border_radius integer | null Border Radius
double_border boolean | null Double Border
fill string | null Fill
fill_pattern string | null Fill Pattern
font string | null Font
font_color string | null Font Color
font_size integer | null Font Size
italic boolean | null Italic
multiple boolean | null Multiple
opacity number | null Opacity
shadow boolean | null Shadow
stroke string | null Stroke
stroke_dash integer | null Stroke Dash
stroke_width integer | null Stroke Width
text_transform string | null Text Transform
three_d boolean | null Three D
underline boolean | null Underline

D2LegendSchema

Structured D2 legend render options.

Properties

Field Type Description
items array[D2LegendElementSchema|D2LegendRelSchema] Items
label string Label Default: Legend.

D2LegendElementSchema

Schema for a D2 legend node sample.

Properties

Field Type Description
type(required) string Legend item discriminator. Must be exactly element.
alias string | null Optional D2 identifier.
classes array[string] Classes
icon string | null Icon
label(required) string Legend item label.
shape string | null Shape
style D2StyleSchema

D2LegendRelSchema

Schema for a D2 legend relationship sample.

Properties

Field Type Description
type(required) string Legend item discriminator. Must be exactly relationship.
alias string | null Optional D2 identifier.
bidirectional boolean Bidirectional Default: false.
classes array[string] Classes
hide_endpoints boolean | null Hide Endpoints
label(required) string Legend item label.
source string | null Source
style D2StyleSchema
target string | null Target