> ## 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.

# get_html: Export Canvas HTML

> Export clean, production-ready HTML from the entire canvas or any component subtree — ready to paste into a React component or serve directly.

The `get_html` tool serializes the canvas to clean HTML and returns it as a string. The output is the same HTML that GrapesJS uses internally — no editor scaffolding, no wrapper divs added by the bridge. You can pass this output directly into a React component using `dangerouslySetInnerHTML`, save it to a file, or use it as a base for further agent processing.

If you pass a `componentId`, the output is scoped to that component's subtree. This is useful when your agent needs to extract a specific section — a hero, a card, a navigation bar — without fetching the entire canvas.

## Parameters

<ParamField path="componentId" type="string">
  The ID of the component whose subtree you want to export. If omitted, the entire canvas is exported. Obtain component IDs from `get_tree` or `get_selection`.
</ParamField>

## Response

<ResponseField name="html" type="string" required>
  The serialized HTML string. Tailwind classes are preserved as-written in the canvas. CSS custom properties referenced by inline styles are not inlined — use `get_css` to retrieve them alongside the HTML.
</ResponseField>

## Example

<CodeGroup>
  ```json request — full canvas theme={null}
  {
    "method": "tools/call",
    "params": {
      "name": "get_html",
      "arguments": {}
    }
  }
  ```

  ```json request — component subtree theme={null}
  {
    "method": "tools/call",
    "params": {
      "name": "get_html",
      "arguments": {
        "componentId": "comp-hero"
      }
    }
  }
  ```
</CodeGroup>

```json response theme={null}
{
  "content": [
    {
      "type": "text",
      "text": "{\"html\": \"<section class=\\\"flex flex-col items-center py-16 bg-white\\\">\\n  <h1 class=\\\"text-4xl font-bold text-gray-900\\\">Welcome to DesignJS</h1>\\n  <p class=\\\"mt-4 text-lg text-gray-600\\\">Build designs your agents can see.</p>\\n  <a href=\\\"/start\\\" class=\\\"mt-8 px-6 py-3 bg-indigo-600 text-white rounded-lg\\\">Get started</a>\\n</section>\"}"
    }
  ]
}
```

<Tip>
  Pair `get_html` with `get_css` to get a complete, self-contained snapshot of the design. When exporting to a React project, also call `get_jsx` if you want Tailwind class names preserved in JSX prop syntax.
</Tip>

<Note>
  The HTML returned does not include `<html>`, `<head>`, or `<body>` wrappers. It represents the inner canvas content only.
</Note>
