# Website to Markdown Converter for LLM & RAG (`withgrokbot/page-to-markdown`) Actor

Convert web pages and websites to clean, token-efficient Markdown for LLMs, RAG and AI agents. Main content only: no nav, footers, ads or cookie banners. Single URLs or same-domain crawls. Respects robots.txt. Pay only for pages that succeed.

- **URL**: https://apify.com/withgrokbot/page-to-markdown.md
- **Developed by:** [402xAgent](https://apify.com/withgrokbot) (community)
- **Categories:** AI, Developer tools, Agents
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.50 / 1,000 page converteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Website to Markdown Converter: clean, LLM-ready content from any web page

Turn web pages into **clean, token-efficient Markdown** for LLMs, RAG and agents. Only the main content is kept: navigation, headers, footers, sidebars, ads, share bars and cookie banners are stripped. **$1.50 per 1,000 pages, and you only pay for pages that succeed.**

### What you get

- **Main content only**: Readability-style extraction plus cleanup.
- **Token-efficient Markdown**: collapsed whitespace, no empty links, absolute URLs, tables kept as GFM tables, code blocks with their language.
- **Optional JSON per page**: `url, title, description, markdown, links, word_count, token_estimate`.
- **Single pages or crawls**: same-domain crawl with `maxPages`, `maxDepth`, and include/exclude globs.
- **Polite by default**: respects robots.txt, per-domain delay, and concurrency and requests-per-minute caps.
- **Honest skips**: login walls, paywalls and 401/403/402 pages are skipped with a `reason`, never charged.

### Input

| Field | Default | Notes |
|---|---|---|
| `startUrls` | required | The pages to convert, or the crawl roots |
| `mode` | `single` | `single` or `crawl` |
| `maxPages` / `maxDepth` | 10 / 1 | Crawl limits; `maxPages` counts successful pages |
| `sameDomainOnly` | true | Follow only the start hosts |
| `includeGlobs` / `excludeGlobs` | \[] | e.g. `https://example.com/docs/**` |
| `outputFormat` | `both` | `markdown`, `json` or `both` |
| `respectRobotsTxt` | true | |
| `maxConcurrency`, `maxRequestsPerMinute`, `sameDomainDelaySecs` | 5, 60, 1 | Politeness settings |

### Output (one dataset item per page)

```json
{"url":"https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/402","title":"402 Payment Required - HTTP | MDN",
 "description":"The HTTP 402 Payment Required client error response status code…","markdown":"# 402 Payment Required\n\nThe HTTP **`402 Payment Required`** …",
 "links":["https://developer.mozilla.org/…"],"word_count":343,"token_estimate":907}
```

A skipped page is recorded as `{"url":…,"skipped":true,"reason":"robots_txt_disallow|login_wall|paywall|auth_required_http_403|http_404|fetch_failed: …"}` and is not charged.

### Pricing

Pay per event: **`page` = $0.0015** for each successfully converted page. Skipped and failed pages cost nothing. Platform usage is included in the event price.

| | Price per 1,000 pages |
|---|---|
| **This Actor** | **$1.50, no subscription** |
| Firecrawl Hobby ($19 for 5,000 credits; $5 per extra 1,000) | $3.80 to $5.00 |
| Firecrawl Standard ($99 for 100,000 credits) | $0.99, but only with a $99/month commitment |
| Apify Website Content Crawler (platform usage) | about $0.20 (raw HTTP) to $0.50–$5 (headless browser) |

### Limits (v0.1)

- Raw HTTP fetch, no JavaScript rendering. Pages that render client-side only come back thin; they are flagged `empty_content` and not charged.
- PDFs and other non-HTML files are skipped.
- `token_estimate` is about characters ÷ 4, not an exact tokenizer count.

### Use cases

- **RAG and vector databases**: crawl a docs site and feed clean Markdown chunks into your embeddings pipeline.
- **LLM context and AI agents**: convert a URL to Markdown before passing it to ChatGPT, Claude or a custom agent.
- **HTML to Markdown for knowledge bases**: archive articles and docs in a readable, portable format.

### FAQ

**How do I convert a web page to Markdown?** Add the URL to `startUrls`, keep `mode` as `single`, and run. Each page becomes one dataset item with a `markdown` field.

**Can it crawl a whole website or docs site?** Yes. Set `mode` to `crawl` and use `maxPages`, `maxDepth` and include/exclude globs. Crawls stay on the same domain by default.

**Does it render JavaScript?** No, v0.1 uses raw HTTP fetch. Client-side-only pages are flagged `empty_content` and not charged.

**What does it cost?** $0.0015 per successfully converted page ($1.50 per 1,000). Skipped and failed pages are free.

Built by withgrokbot.

# Actor input Schema

## `startUrls` (type: `array`):

Pages to convert (single mode) or crawl roots (crawl mode).

## `mode` (type: `string`):

single = convert just the start URLs; crawl = follow links up to maxPages / maxDepth.

## `maxPages` (type: `integer`):

Stop after this many successful pages.

## `maxDepth` (type: `integer`):

0 = start URLs only.

## `sameDomainOnly` (type: `boolean`):

Only follow links on the start URLs' hostnames.

## `includeGlobs` (type: `array`):

Only enqueue URLs matching one of these (e.g. https://example.com/docs/\*\*).

## `excludeGlobs` (type: `array`):

Never enqueue URLs matching these.

## `outputFormat` (type: `string`):

markdown = url, title, markdown; json = metadata + links + content_markdown; both = everything.

## `respectRobotsTxt` (type: `boolean`):

Skip URLs disallowed for our crawler (recorded with reason robots_txt_disallow).

## `maxConcurrency` (type: `integer`):

Maximum parallel requests.

## `maxRequestsPerMinute` (type: `integer`):

Global request rate cap.

## `sameDomainDelaySecs` (type: `integer`):

Minimum gap between requests to the same domain.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://docs.apify.com/academy/web-scraping-for-beginners"
    }
  ],
  "mode": "single",
  "maxPages": 10,
  "maxDepth": 1,
  "sameDomainOnly": true,
  "includeGlobs": [],
  "excludeGlobs": [],
  "outputFormat": "both",
  "respectRobotsTxt": true,
  "maxConcurrency": 5,
  "maxRequestsPerMinute": 60,
  "sameDomainDelaySecs": 1
}
```

# Actor output Schema

## `pages` (type: `string`):

One item per page: url, title, markdown, status.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://docs.apify.com/academy/web-scraping-for-beginners"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("withgrokbot/page-to-markdown").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "startUrls": [{ "url": "https://docs.apify.com/academy/web-scraping-for-beginners" }] }

# Run the Actor and wait for it to finish
run = client.actor("withgrokbot/page-to-markdown").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://docs.apify.com/academy/web-scraping-for-beginners"
    }
  ]
}' |
apify call withgrokbot/page-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,withgrokbot/page-to-markdown"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/JCMbtT7sZeE8kiVdV/builds/SWFxhkYoKAzoyTy4w/openapi.json
