/markdown - Extract Markdown from a webpage
The /markdown endpoint retrieves a webpage's content and converts it into Markdown format. You can specify a URL and optional parameters to refine the extraction process.
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdownYou must provide either url or html:
url(string)html(string)
- Normalize content for downstream processing (summaries, diffs, embeddings)
- Save articles or docs for editing or storage
- Strip styling/scripts and keep readable content + links
This example fetches the Markdown representation of a webpage.
curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer <apiToken>' \ -d '{ "url": "https://example.com" }' "success": true, "result": "# Example Domain\n\nThis domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)"}import Cloudflare from "cloudflare";
const client = new Cloudflare({ apiToken: process.env["CLOUDFLARE_API_TOKEN"],});
const markdown = await client.browserRendering.markdown.create({ account_id: process.env["CLOUDFLARE_ACCOUNT_ID"], url: "https://developers.cloudflare.com/",});
console.log(markdown);Instead of fetching the content by specifying the URL, you can provide raw HTML content directly.
curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer <apiToken>' \ -d '{ "html": "<div>Hello World</div>" }'{ "success": true, "result": "Hello World"}You can refine the Markdown extraction by using the rejectRequestPattern parameter. In this example, requests matching the given regex pattern (such as CSS files) are excluded.
curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer <apiToken>' \ -d '{ "url": "https://example.com", "rejectRequestPattern": ["/^.*\\.(css)/"] }'{ "success": true, "result": "# Example Domain\n\nThis domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)"}For JavaScript-heavy pages or Single Page Applications (SPAs), the default page load behavior may return empty or incomplete results. This happens because the browser considers the page loaded before JavaScript has finished rendering the content.
The simplest solution is to use the gotoOptions.waitUntil parameter set to networkidle0 or networkidle2:
{ "url": "https://example.com", "gotoOptions": { "waitUntil": "networkidle0" }}For faster responses, advanced users can use waitForSelector to wait for a specific element instead of waiting for all network activity to stop. This requires knowing which CSS selector indicates the content you need has loaded. For more details, refer to REST API timeouts.
You can change the user agent at the page level by passing userAgent as a top-level parameter in the JSON body. This is useful if the target website serves different content based on the user agent.
If you have questions or encounter an error, see the Browser Rendering FAQ and troubleshooting guide.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2026 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark
-