---
title: /markdown - Extract Markdown from a webpage · Browser Rendering docs
description: 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.
lastUpdated: 2025-04-29T16:56:49.000Z
source_url:
  html: https://dependabot-npm-and-yarn-pretty-bytes-7-0-0.preview.developers.cloudflare.com/browser-rendering/rest-api/markdown-endpoint/index.md
  md: https://dependabot-npm-and-yarn-pretty-bytes-7-0-0.preview.developers.cloudflare.com/browser-rendering/rest-api/markdown-endpoint/
---

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.

## Basic usage

### Using a URL

* curl

  This example fetches the Markdown representation of a webpage.

  ```bash
  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"
    }'
  ```

  ```json
    "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)"
  }
  ```

* TypeScript SDK

  ```typescript
  import Cloudflare from "cloudflare";


  const client = new Cloudflare({
    apiEmail: process.env["CLOUDFLARE_EMAIL"], // This is the default and can be omitted
    apiKey: process.env["CLOUDFLARE_API_KEY"], // This is the default and can be omitted
  });


  const markdown = await client.browserRendering.markdown.create({
    account_id: "account_id",
  });


  console.log(markdown);
  ```

### Use raw HTML

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

```bash
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>"
  }'
```

```json
{
  "success": true,
  "result": "Hello World"
}
```

## Advanced usage

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.

```bash
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)/"]
  }'
```

```json
{
  "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)"
}
```

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