Cloudflare Browser Run & The /crawl API: Headless Web Automation at Edge Scale
> Cloudflare Workers Browser Run and the new /crawl API bring serverless Chromium rendering and recursive site crawling to AI agents and RAG pipelines. Includes code examples and cost optimization strategies.
🎧 Listen — ~4 min
Ready · Cloudflare Browser Run & The /cr
Published August 6, 2026 · Category: Developer Tools · Reading time: ~14 min
For AI agents, web crawlers, and RAG pipelines, scraping data from modern websites is a minefield. SPA single-page apps require full JavaScript rendering; static sites need sub-second light fetches; and large-scale site audits require recursive link crawling while strictly adhering to robots.txt directives and rate limits.
Managing self-hosted Puppeteer or Playwright clusters on Kubernetes is notoriously expensive, prone to memory leaks, and difficult to scale globally.
Cloudflare solved this with Workers Browser Run and the new /crawl API endpoint: a headless, programmable browser engine running on Cloudflare's global edge network.
In this deep dive, we explore how Browser Run handles both static and dynamic rendering, how the new /crawl API traverses entire websites recursively, and how to build high-performance data ingestion pipelines for AI agents.
Part 1: Browser Run Architecture — Headless Chromium at the Edge
Cloudflare Workers Browser Run eliminates the overhead of managing browser infrastructure by exposing a serverless REST & WebSocket API over pooled Chromium instances:
┌────────────────────────────────────────┐
│ AI Agent / RAG Pipeline │
└───────────────────┬────────────────────┘
│
▼
┌────────────────────────────────────────┐
│ Cloudflare Browser Run Control API │
└─────────┬────────────────────┬─────────┘
│ │
┌────────────────────────┘ └────────────────────────┐
▼ ▼
┌─────────────────────────────┐ ┌─────────────────────────────┐
│ Static Render Mode │ │ Full Browser Mode │
│ - High-speed HTTP Fetch │ │ - Full Chromium V8 JS Exec │
│ - Zero browser overhead │ │ - Screenshot & PDF Render │
│ - Light Markdown/Text │ │ - DOM Interaction & Click │
└─────────────────────────────┘ └─────────────────────────────┘Key Features of Browser Run:
- Zero Infrastructure Maintenance: Spin up Chromium browsers on-demand without managing server memory, Chrome binary dependencies, or browser pools.
- Dual Rendering Modes: Switch dynamically between ultra-fast static HTTP fetching (
render: false) and full JavaScript evaluation (render: true). - Automated Bot Compliance: Browser Run identifies itself with clear bot headers (e.g.,
Cloudflare-AI-Search) and respectsrobots.txtandcrawl-delaydirectives out-of-the-box.
Part 2: The New /crawl API Endpoint
While individual Browser Run page loads capture single pages, the new /crawl API endpoint automates full-site traversal for RAG vector indexers and LLM knowledge bases.
/crawl Parameter | Type | Description |
|---|---|---|
url | string | The starting root URL for recursive crawling |
depth | number | Maximum link depth to follow (Default: 2, Max: 10) |
limit | number | Maximum total pages to fetch across the domain |
render | boolean | true = Full Chromium rendering; false = Fast static HTML fetch |
output_format | string | Output payload format: markdown, text, html, or pdf |
respect_robots | boolean | Honor site robots.txt directives (Default: true) |
Part 3: Code Example — Automated Site Crawling for RAG Ingestion
Here is a complete Node.js script showing how to invoke Cloudflare Browser Run's /crawl API to extract clean Markdown for vector database embedding:
1import fetch from 'node-fetch';
2
3const CLOUDFLARE_ACCOUNT_ID = process.env.CLOUDFLARE_ACCOUNT_ID;
4const CLOUDFLARE_API_TOKEN = process.env.CLOUDFLARE_API_TOKEN;
5
6interface CrawlPageResult {
7 url: string;
8 status: number;
9 markdown: string;
10 links: string[];
11}
12
13async function crawlSiteForRAG(targetUrl: string): Promise<CrawlPageResult[]> {
14 console.log(`[1/3] Initiating recursive crawl job for: ${targetUrl}`);
15
16 const response = await fetch(
17 `https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/browser-rendering/crawl`,
18 {
19 method: 'POST',
20 headers: {
21 'Authorization': `Bearer ${CLOUDFLARE_API_TOKEN}`,
22 'Content-Type': 'application/json',
23 },
24 body: JSON.stringify({
25 url: targetUrl,
26 depth: 3,
27 limit: 50,
28 render: true, // Enable JS evaluation for Single Page Applications
29 output_format: 'markdown',
30 respect_robots: true,
31 }),
32 }
33 );
34
35 if (!response.ok) {
36 throw new Error(`Crawl API error: ${response.statusText}`);
37 }
38
39 const data = await response.json() as any;
40 console.log(`[2/3] Crawl completed. Pages processed: ${data.result.pages.length}`);
41
42 // Process Markdown outputs for vector embedding
43 const results: CrawlPageResult[] = data.result.pages.map((page: any) => ({
44 url: page.url,
45 status: page.status,
46 markdown: page.markdown,
47 links: page.outbound_links,
48 }));
49
50 console.log(`[3/3] Ready for vector indexing. First page preview:`);
51 console.log(results[0].markdown.slice(0, 300));
52
53 return results;
54}
55
56// Trigger crawl on documentation site
57crawlSiteForRAG('https://docs.example.com').catch(console.error);Part 4: Production Best Practices & Cost Optimization
When deploying Browser Run and the /crawl API in commercial AI pipelines, follow these engineering guidelines:
- Use Static Mode First: Test your target domain with
render: falsefirst. Static fetches consume 10x fewer Workers AI credits and run in a fraction of the time compared to spinning up full V8 Chromium contexts. - Chunking & Token Management: Utilize Browser Run's
output_format: 'markdown'parameter. Raw HTML often injects thousands of useless navigation and CSS tokens into LLM context windows; Markdown output reduces token waste by up to 80%. - Queue-Based Asynchronous Crawling: For large sites with thousands of URLs, dispatch crawl jobs to Cloudflare Queues or Durable Objects to prevent Worker timeout limits.
The Bottom Line
Cloudflare Browser Run and the /crawl API represent a massive upgrade for developers building web scrapers, RAG vector indexers, and autonomous browser agents. By providing serverless, globally distributed Chromium clusters at scale, Cloudflare has eliminated the complexity of self-hosted browser automation.
Sources & Official References
- Cloudflare Workers Browser Rendering Documentation
- Cloudflare Browser Run /crawl API Reference
- Cloudflare AI Agents Week Product Updates
Hire me: Building high-throughput web crawling infrastructure, custom RAG ingestion pipelines, or serverless browser automation? Reach out through /hire.
Keep reading
Related reading
⚡ Daily AI Model Drop — Get Kimi K3 benchmarks before Twitter
Join 2,400+ AI engineers. 1 email/day, no spam, unsubscribe anytime