# URL to Markdown: Web Page to Markdown for LLMs & RAG (`fecklesspleb/url-to-markdown`) Actor

Convert URLs and web pages to clean Markdown or plain text for LLMs, RAG and AI agents. HTML to Markdown with main-content extraction (no menus, ads or footers), or keep the full page. Title, metadata, links and word count per page. Fast HTTP, no browser, robots.txt respected. $0.50 per 1,000 pages.

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

## Pricing

Pay per event

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

## URL to Markdown: Web Page and Website to Markdown for LLMs & RAG

Convert a list of URLs into clean **Markdown** or plain text, ready for LLMs, RAG pipelines, AI agents and content analysis. For each page you get the main content as Markdown, with headings, lists, tables and absolute links kept (images dropped), and menus, cookie banners, ads and footers dropped. Each page also comes with its title, meta description, language, canonical URL, published date (when the page declares one) and a word count.

**At a glance:** $0.50 per 1,000 pages, plus $0.00005 per run start. Pay per result with no subscription. Set a maximum cost per run, export to JSON, CSV or Excel, or call it from the Apify API, Make, Zapier or n8n.

It uses plain HTTP with no browser, so it is fast and cheap. robots.txt is respected (RFC 9309) on every request, including redirects.

### What it does

- **URL to Markdown:** paste a list of URLs and get one dataset row per page.
- **HTML to Markdown, main content only:** boilerplate is removed with trafilatura. If nothing is found, it falls back to the whole page.
- **Website to Markdown:** give it the page URLs of a docs site, help center or blog (for example from its sitemap) and get the whole set as Markdown in one run. It converts the URLs you give it and does not crawl links by itself. You can also put the sitemap URL in `sitemapUrls`: it reads the sitemap (including sitemap index files and `.xml.gz` files) and converts up to `maxSitemapUrls` pages listed there (default 100).
- **LLM-ready text:** choose `text` output for plain text, and use `maxCharsPerPage` to fit a context window.

### Use cases

- Feed documentation, blog posts or help-center pages into a vector database for RAG.
- Give an AI agent or LLM a clean, token-efficient version of a page instead of raw HTML.
- Build training or evaluation corpora from a list of URLs you are allowed to use.
- Monitor content changes on key pages: schedule the Actor and diff the Markdown.
- Export pages from an old CMS to Markdown for a static site migration.

### Input

```json
{
  "urls": [{"url": "https://docs.python.org/3/tutorial/appetite.html"}],
  "sitemapUrls": [],
  "maxSitemapUrls": 100,
  "contentMode": "main",
  "outputFormat": "markdown",
  "includeLinks": true,
  "maxCharsPerPage": 0,
  "includeRawHtml": false,
  "maxConcurrency": 10,
  "maxResults": 0
}
```

| Field | Default | What it does |
|---|---|---|
| `urls` | Python tutorial page | Pages to convert. Bare domains get `https://` added. Every URL here is converted as one page, as before, even a sitemap URL: put sitemaps in `sitemapUrls`. No longer a required field, so an input with only `sitemapUrls` is valid; if `urls` is empty and no sitemap is given, the Python tutorial sample page is converted. |
| `sitemapUrls` | empty | Sitemaps to read. Sitemap index files are followed up to 3 levels deep, `.xml.gz` files are unpacked and plain-text URL lists work too. Page URLs are taken in sitemap order, at most `maxSitemapUrls` of them per run (all sitemaps together), and at most 100 sitemap files are read. robots.txt is checked for the sitemap host and for every page. Reading sitemaps is free; only converted pages are charged. If a sitemap gives no page URLs, the dataset gets a free status row (`recordType: "status"`) saying why. |
| `contentMode` | `main` | `main` is main content only (recommended). `page` is the whole page without nav, header and footer. `full` is everything. |
| `outputFormat` | `markdown` | `markdown` or `text`. |
| `includeLinks` | `true` | Keep hyperlinks, made absolute, in main-content Markdown. |
| `maxCharsPerPage` | `0` | Cut long pages to this many characters. 0 means no limit. |
| `includeRawHtml` | `false` | Also store the original HTML. This makes the dataset much larger. |
| `maxConcurrency` | `10` (max 30) | Pages fetched in parallel. Requests to the same host are spaced at least 0.5 s apart, or longer if robots.txt sets a crawl delay, so one site runs at about 2 pages per second. |
| `maxSitemapUrls` | `100` (max 10,000) | Most page URLs taken from `sitemapUrls` in one run. This caps what a sitemap can cost: at the default, at most 100 pages × $0.0005 = $0.05 per run from sitemaps. If `maxResults` is above 0, the lower of the two applies. Has no effect on `urls`. |
| `maxResults` | `0` | Stop after this many converted pages. 0 means no cap. Sitemap page URLs are capped by `maxSitemapUrls` even when this is 0. |

### Output example

Real output for the URL above, with `maxCharsPerPage` set to 400:

```json
{
  "url": "https://docs.python.org/3/tutorial/appetite.html",
  "finalUrl": "https://docs.python.org/3/tutorial/appetite.html",
  "statusCode": 200,
  "contentType": "text/html",
  "title": "1. Whetting Your Appetite — Python 3.15.2 documentation",
  "description": "If you do much work on computers, eventually you find that there’s some task you’d like to automate. ...",
  "language": "en",
  "canonicalUrl": "https://docs.python.org/3/tutorial/appetite.html",
  "publishedAt": null,
  "markdown": "# 1. Whetting Your Appetite\n\nIf you do much work on computers, eventually you find that there’s some task you’d like to automate. ...",
  "wordCount": 75,
  "charCount": 400,
  "truncated": true,
  "error": null,
  "fetchedAt": "2026-10-28T03:40:00+00:00"
}
```

Pages that fail still get a row with `error` set, and those rows are free. Failures include HTTP errors, timeouts, pages disallowed by robots.txt, and files that are not text. Supported types are HTML, XHTML, plain text, Markdown, JSON and XML. PDFs, images and other binaries return an error row.

### Pricing

Pay per converted page: **$0.50 per 1,000 pages** ($0.0005 per page), plus the standard Apify run start event of $0.00005 per run. Failed pages are not charged. Set **Maximum cost per run**, or `maxResults`, and the Actor stops cleanly when the limit is reached. Pages from `sitemapUrls` are capped by `maxSitemapUrls` (default 100), so a large sitemap cannot run up an unexpected bill; reading the sitemap files is free.

### Use with AI agents / MCP

AI agents can run this Actor as a tool through [Apify's MCP server](https://docs.apify.com/platform/integrations/mcp). Add this server URL to your MCP client (Claude, Cursor, VS Code, OpenAI Agents SDK, LangChain and others) and sign in with OAuth, or send your Apify token as `Authorization: Bearer <token>`:

```text
https://mcp.apify.com?tools=fecklesspleb/url-to-markdown
```

The tool is named `fecklesspleb--url-to-markdown`. Agents can also find it with `search-actors` and run it with `call-actor`. The run returns a dataset ID; read the rows with `get-dataset-items`, and pass `fields` (for example `url,title,markdown,error`) to keep the response small.

Minimal tool input:

```json
{"urls": [{"url": "https://docs.python.org/3/tutorial/appetite.html"}, {"url": "https://example.invalid/page"}], "maxCharsPerPage": 300}
```

The output of this input (real rows from a run, `description` and `markdown` shortened):

```json
[
  {
    "url": "https://docs.python.org/3/tutorial/appetite.html",
    "finalUrl": "https://docs.python.org/3/tutorial/appetite.html",
    "statusCode": 200,
    "contentType": "text/html",
    "title": "1. Whetting Your Appetite — Python 3.15.2 documentation",
    "description": "If you do much work on computers, eventually you find that there’s some task you’d like to automate. ...",
    "language": "en",
    "canonicalUrl": "https://docs.python.org/3/tutorial/appetite.html",
    "publishedAt": null,
    "markdown": "# 1. Whetting Your Appetite\n\nIf you do much work on computers, eventually you find ...",
    "wordCount": 56,
    "charCount": 300,
    "truncated": true,
    "error": null,
    "fetchedAt": "2026-11-03T15:31:18.606861+00:00"
  },
  {"url": "https://example.invalid/page", "error": "DNS or connection error", "fetchedAt": "2026-11-03T15:31:18.607370+00:00"}
]
```

Tips for agents:

- Cost is $0.0005 per converted page; rows with `error` set are free. Set `maxResults`, and set `maxTotalChargeUsd` in the run options (`callOptions` in `call-actor`) to cap a run.
- Check `error` first: it is `null` when the page was converted. Failed rows have only `url`, `error`, `fetchedAt` and, when the server answered, `finalUrl`, `statusCode` and `contentType`.
- Use `maxCharsPerPage` to fit a context window, and `"outputFormat": "text"` for plain text (the content is then in `text`, not `markdown`).
- To convert a whole docs site, pass its sitemap in `sitemapUrls` and set `maxSitemapUrls` (default 100). A sitemap that gives no page URLs returns a free row with `recordType: "status"`.
- The `RUN_SUMMARY` record in the run's key-value store shows pages converted (`ok`), failed and charged, and how many page URLs came from sitemaps.

### Limits

- No JavaScript rendering. Pages that build their content in the browser, such as some single-page apps, may return little text. Most documentation, blogs, news and marketing sites render on the server and work well.
- Pages behind a login are not supported.
- On the Apify platform, URLs and sitemaps whose address is private, loopback or link-local (also after a redirect, and for URLs listed in a sitemap) are not fetched. Their rows are free: `error: "not fetched: private, loopback and link-local addresses are not allowed"`.
- PDFs and other binary files are not converted.
- Responses larger than 15 MB are cut.
- It does not follow links on pages. Give it the list of URLs you want in `urls`, or a sitemap in `sitemapUrls`. Pages missing from the sitemap are not found. Sitemap URLs placed in `urls` are converted as a page, not expanded.
- If robots.txt cannot be read because the server answers HTTP 429 or 5xx, that host is treated as disallowed and its pages are skipped.

**What happens with invalid input?** If the input is not a JSON object, or a field has the wrong type (for example a number where a list of URLs is expected, or `"abc"` for a number), the run fetches nothing and ends with one free status row: `Invalid input, nothing was fetched and no results were charged: <reason>`. No results are charged for it; the standard Apify start event still applies.

### Is this legal?

The Actor only fetches the URLs you give it. It identifies itself with its own user agent, spaces requests to each host, and obeys robots.txt. You are responsible for having the right to use the content you convert, in line with each site's terms and copyright. It does not log in or bypass any access control.

# Changelog

This Actor's version history is a separate document: https://apify.com/fecklesspleb/url-to-markdown/changelog.md

# Actor input Schema

## `urls` (type: `array`):

Pages to convert, one dataset row per URL, as objects: \[{"url": "https://docs.python.org/3/tutorial/appetite.html"}]. A URL without http(s):// gets https:// added and duplicates are removed. Links on the pages are not followed, and a sitemap URL put here is converted as a page (use sitemapUrls instead). Optional when sitemapUrls is given; with an empty input the default Python tutorial page is converted.

## `sitemapUrls` (type: `array`):

Optional XML sitemaps (for example https://example.com/sitemap.xml) whose pages you want converted. Sitemap index files are followed up to 3 levels deep, gzip (.xml.gz) and plain-text URL lists work too. robots.txt is checked for the sitemap host as for pages. Page URLs are taken in sitemap order, at most Max sitemap page URLs of them (default 100), and each converted page is charged like any other page, so one sitemap costs at most Max sitemap page URLs x the page price. Reading the sitemap itself is free. A sitemap that yields no page URL gives one free status row. If you give only sitemaps, the sample URL default in URLs is skipped.

## `maxSitemapUrls` (type: `integer`):

Most page URLs taken from all sitemapUrls together in one run, 1 to 10,000. Default 100, so a sitemap run costs at most 100 x $0.0005 = $0.05 in page events. If maxResults is above 0, the lower of the two applies. Has no effect on urls.

## `contentMode` (type: `string`):

"main" (default): main content only, boilerplate removed with trafilatura, falling back to the whole page if nothing is found. "page": whole page without nav, header and footer. "full": whole page including navigation.

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

"markdown" (default) puts the content in the markdown field, keeping headings, lists, tables and links. "text" puts plain text in the text field instead.

## `includeLinks` (type: `boolean`):

If true (default), hyperlinks are kept as absolute Markdown links in main-content mode. Set false for shorter text.

## `maxCharsPerPage` (type: `integer`):

Cut the markdown or text of each page to this many characters, e.g. 4000 to fit an LLM context window; truncated is then true. Default 0 = no limit.

## `includeRawHtml` (type: `boolean`):

If true, each row also gets html with the original page source. Default false; it makes rows much larger.

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

Pages fetched in parallel, 1 to 30. Default 10. Requests to the same host are spaced at least 0.5 s apart, longer if robots.txt sets a crawl delay.

## `maxResults` (type: `integer`):

Stop after this many converted (charged) pages. Default 0 = no cap. Free rows for failed pages do not count. Sitemap page URLs are always capped by maxSitemapUrls; if this is above 0, the lower of the two applies.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://docs.python.org/3/tutorial/index.html"
    }
  ],
  "maxSitemapUrls": 100,
  "contentMode": "main",
  "outputFormat": "markdown",
  "includeLinks": true,
  "maxCharsPerPage": 0,
  "includeRawHtml": false,
  "maxConcurrency": 10,
  "maxResults": 0
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# 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 = {
    "urls": [
        {
            "url": "https://docs.python.org/3/tutorial/index.html"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("fecklesspleb/url-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 = { "urls": [{ "url": "https://docs.python.org/3/tutorial/index.html" }] }

# Run the Actor and wait for it to finish
run = client.actor("fecklesspleb/url-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 '{
  "urls": [
    {
      "url": "https://docs.python.org/3/tutorial/index.html"
    }
  ]
}' |
apify call fecklesspleb/url-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,fecklesspleb/url-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/x6MtcpGr7rlbZj3Uz/builds/WxcEryZo9Vp1yetuh/openapi.json
