# Site Converter (Site-to-Code)

> Convert a live website URL (e.g. a Squarespace page) into clean, editable HTML with a vision model — from the dashboard, the CLI, the API, MCP, or by asking the Divinci agent.

**Site Converter** turns a live web page into clean, editable HTML. Divinci
screenshots the URL server-side and a vision model regenerates it as a
self-contained document (Tailwind, plain CSS, or Bootstrap) — real images are
cropped from the capture and hosted for you. Give it a `sitemap.xml` and it
converts every page, stitching the navigation between them.

It's the same feature across every surface: the dashboard, the CLI, the REST
API, MCP, and the Divinci agent.

## From the dashboard

Open a workspace → **Data Sources → Site Converter**. Paste a URL, pick an
output stack under **Advanced** (default Tailwind), optionally toggle
**Multi-page** and give a sitemap, then **Convert**. Each job shows a live
status (`queued → screenshotting → generating → done`); when it's done you get
a sandboxed preview, a **Download**, and thumbnails of the extracted assets. The
page is findable from unified search ("Site Converter", "convert website",
"squarespace").

## From the CLI

```bash
# Single page → clean HTML
divinci site export https://your-site.squarespace.com --out index.html

# A specific page + stack
divinci site export https://example.com/about --stack html_css --out about.html

# Whole site from a sitemap → one file per page
divinci site export https://example.com --sitemap https://example.com/sitemap.xml --out-dir ./site

# Fire-and-forget: print the jobId and exit
divinci site export https://example.com --no-wait
# → poll later:
divinci site get <jobId>
```

## From the Server SDK

```ts

const divinci = createServerClient({ apiKey: process.env.DIVINCI_API_KEY });

// Submit + poll to completion
const job = await divinci.siteToCode.createAndWait(whitelabelId, "https://example.com", {
  stack: "html_tailwind",
});
console.log(job.status, job.html?.length, "bytes");

// Or manage the job yourself
const queued = await divinci.siteToCode.create(whitelabelId, "https://example.com");
const latest = await divinci.siteToCode.get(whitelabelId, queued._id);
const history = await divinci.siteToCode.list(whitelabelId);
```

## From MCP

The MCP server exposes `site_export` and `site_get` (scopes `release:write` /
`release:read`) — see the [Tool Catalog](/mcp/tool-catalog).

## Ask the Divinci agent

You can just ask the in-app assistant: *"Convert https://my-site.com to clean
HTML."* The agent starts the job for you and can report when it's done.

<Aside type="caution">
**It costs money, and the agent confirms first.** When per-job pricing is
enabled, each conversion charges the workspace wallet (typically **$1.00**),
escrowed up front and refunded automatically if the job fails — you pay only for
successful conversions. The agent **always discloses the cost and asks for your
confirmation** before starting a paid conversion.
</Aside>

## The REST API

All surfaces call the same whitelabel-scoped endpoints (admin / `editConfig`):

| Method | Path | Purpose |
|---|---|---|
| `POST` | `/white-label/:wl/site-to-code` | Submit a job (`{ url, stack?, sitemapUrl? }`) → `202` + job |
| `GET`  | `/white-label/:wl/site-to-code` | List this workspace's jobs (History) |
| `GET`  | `/white-label/:wl/site-to-code/:jobId` | Poll one job |
| `GET`  | `/white-label/:wl/site-to-code/config` | Current per-job price (for cost disclosure) |

<Aside type="tip">
**Convert sites you own.** Site Converter is built for migrating *your* site onto
code and infrastructure you control. Only convert pages you own or are
authorized to reproduce.
</Aside>

See the [`SiteToCodeJob` type reference](/reference/types) for the full job shape.
