> ## Documentation Index
> Fetch the complete documentation index at: https://opencanvas.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# delete_nodes: Remove Canvas Components

> Remove one or more components and all of their children from the DesignJS canvas by component ID, with a count of how many nodes were deleted.

The `delete_nodes` tool removes components from the canvas by their IDs. Each deleted component takes its entire child subtree with it — all nested elements are removed in a single call. The response tells you how many total nodes (including children) were deleted, which is useful for confirming the operation completed as expected.

You can delete multiple components in one call by passing several IDs in the array. This is more efficient than calling `delete_nodes` repeatedly and reduces the number of round-trips between your agent and the canvas.

## Parameters

<ParamField path="componentIds" type="string[]" required>
  An array of component IDs to remove from the canvas. Each ID should correspond to a component currently on the canvas. Obtain IDs from `get_tree`, `get_selection`, `add_components`, or `list_artboards`. Non-existent IDs are silently ignored.
</ParamField>

## Response

<ResponseField name="deleted" type="number" required>
  The total count of nodes removed from the canvas, including all descendants of the targeted components. For example, deleting a `<section>` that contains three child `<div>` elements returns `deleted: 4`.
</ResponseField>

## Example

<CodeGroup>
  ```json request — delete a single component theme={null}
  {
    "method": "tools/call",
    "params": {
      "name": "delete_nodes",
      "arguments": {
        "componentIds": ["comp-old-banner"]
      }
    }
  }
  ```

  ```json request — delete multiple components theme={null}
  {
    "method": "tools/call",
    "params": {
      "name": "delete_nodes",
      "arguments": {
        "componentIds": ["comp-hero", "comp-footer", "comp-sidebar"]
      }
    }
  }
  ```
</CodeGroup>

```json response theme={null}
{
  "content": [
    {
      "type": "text",
      "text": "{\"deleted\": 7}"
    }
  ]
}
```

<Warning>
  Deletion is immediate and removes child nodes permanently from the canvas state. The operation can be undone using **Cmd+Z** (or **Ctrl+Z**) in the editor, but there is no undo API — your agent cannot programmatically reverse a deletion.
</Warning>

<Tip>
  To delete whatever the user currently has selected in the editor, call `get_selection` first to retrieve the IDs, then pass the returned array directly to `delete_nodes`. This lets users point to what they want removed without typing IDs.
</Tip>
