Skip to content
Cloudflare Docs

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

Endpoint

https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown

Required fields

You must provide either url or html:

  • url (string)
  • html (string)

Common use cases

  • Normalize content for downstream processing (summaries, diffs, embeddings)
  • Save articles or docs for editing or storage
  • Strip styling/scripts and keep readable content + links

Basic usage

Convert a URL to Markdown

This example fetches the Markdown representation of a webpage.

Terminal window
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)"
}

Convert raw HTML to Markdown

Instead of fetching the content by specifying the URL, you can provide raw HTML content directly.

Terminal window
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"
}

Advanced usage

Exclude unwanted requests (for example, CSS)

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.

Terminal window
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)"
}

Set a custom user agent

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.

Potential use-cases

  1. Content extraction: Convert a blog post or article into Markdown format for storage or further processing.
  2. Static site generation: Retrieve structured Markdown content for use in static site generators like Jekyll or Hugo.
  3. Automated summarization: Extract key content from web pages while ignoring CSS, scripts, or unnecessary elements.