# Website & URL to Markdown for LLMs (HTML to Markdown) (`dofunbiz/web-to-markdown`) Actor

Convert any web page to clean Markdown for LLMs and RAG. Extracts the main article, drops nav/ads/boilerplate, keeps links, headings and tables. Metadata + chunks.

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

## Pricing

from $1.00 / 1,000 converted pages

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 & URL to Markdown for LLMs (HTML to Markdown)

Turn any web page into **clean Markdown** that's ready to feed into ChatGPT, Claude, embeddings or a RAG pipeline. Paste URLs, and get back just the article, with the navigation, ads, cookie banners and footers stripped out.

### What you get, per page

- **Main-content extraction**: finds the article and drops menus, sidebars, share buttons, related-posts and other boilerplate.
- **Clean Markdown**: headings, paragraphs, lists, tables, blockquotes, code blocks, and links (made absolute) preserved.
- **Metadata**: title, description, author, published date, site name and language.
- **RAG chunks**: optional splitting on paragraph boundaries, with overlap, ready for embedding.
- A **.md file per page**, plus a structured JSON row for your pipeline.

### Why this and not a raw HTML scraper

LLMs choke on raw HTML: it's bloated with tags, scripts and navigation that waste tokens and confuse the model. This Actor returns only the readable content as Markdown, so your prompts are smaller, cheaper and more accurate.

### Who it's for

- **AI and RAG builders**: ingest docs, articles and knowledge bases into a vector database.
- **Automation workflows** (Make, Zapier, n8n, LangChain): turn a URL into clean text in one call.
- **Researchers and writers**: pull a readable copy of an article for summarizing or analysis.

### Input

| Field | Example |
|---|---|
| Page URLs | `https://en.wikipedia.org/wiki/Markdown` |
| Main content only | on |
| RAG chunk size | `2000` characters (0 = off) |

### Example output (excerpt)

From the Wikipedia article on Markdown:

```markdown
**Markdown** is a [lightweight markup language](https://en.wikipedia.org/wiki/Lightweight_markup_language)
for creating [formatted text](https://en.wikipedia.org/wiki/Formatted_text) using a plain-text editor.
[John Gruber](https://en.wikipedia.org/wiki/John_Gruber) created Markdown in 2004...
```

Each row also includes `title`, `description`, `author`, `siteName`, `wordCount`, optional `chunks` and a `markdownFile` key.

### Pricing

**Pay per page converted.** Failed fetches and non-HTML URLs are never charged. The Actor respects Apify's maximum-charge-per-run setting.

### Good to know

- It's a fast HTTP fetch with no browser, so it reads the HTML the server returns. Pages that render their content only with JavaScript may come back thin; for those, pair it with a browser-based crawler.
- It respects robots.txt by default and identifies itself as `WebToMarkdownBot`.
- For PDF files, use [PDF to Text & Markdown Extractor](https://apify.com/dofunbiz/pdf-to-markdown).
- Only convert pages you have the right to use.

# Actor input Schema

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

Web page URLs to convert to Markdown. One row per page.

## `mainContentOnly` (type: `boolean`):

On = extract just the article/main content (recommended for AI). Off = convert the whole page body.

## `chunkSize` (type: `integer`):

If > 0, also split each page into chunks of about this many characters on paragraph boundaries (for embeddings/RAG). 0 = no chunks.

## `chunkOverlap` (type: `integer`):

Characters repeated between consecutive chunks.

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

Skip pages the site's robots.txt disallows. Turn off only for sites you own.

## Actor input object example

```json
{
  "urls": [
    "https://en.wikipedia.org/wiki/Markdown"
  ],
  "mainContentOnly": true,
  "chunkSize": 0,
  "chunkOverlap": 200,
  "respectRobotsTxt": true
}
```

# Actor output Schema

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

One row per page: Markdown, title, metadata, word count, optional chunks.

## `markdownFiles` (type: `string`):

Full Markdown file per page.

# 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": [
        "https://en.wikipedia.org/wiki/Markdown"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dofunbiz/web-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": ["https://en.wikipedia.org/wiki/Markdown"] }

# Run the Actor and wait for it to finish
run = client.actor("dofunbiz/web-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": [
    "https://en.wikipedia.org/wiki/Markdown"
  ]
}' |
apify call dofunbiz/web-to-markdown --silent --output-dataset

```

## MCP server setup

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