# HTML to Markdown Converter: Bulk URLs for LLM & RAG (`dataforgehq/html-to-markdown-converter`) Actor

Convert web pages or raw HTML to clean Markdown in bulk: main content or full page, GFM tables, absolute links, YAML frontmatter, token estimate and RAG chunks. No browser. $0.50 per 1,000 pages; failed pages free.

- **URL**: https://apify.com/dataforgehq/html-to-markdown-converter.md
- **Developed by:** [Andrew Shamah](https://apify.com/dataforgehq) (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

from $0.50 / 1,000 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

## HTML to Markdown Converter – bulk web pages to clean Markdown for LLMs & RAG

Turn any list of **web pages (or raw HTML)** into **clean Markdown** ready for ChatGPT/Claude prompts, RAG pipelines, vector databases, docs migration or archiving. Fast HTTP fetch, no browser, so it's cheap and quick.

### Features

- **URLs or raw HTML** input (`htmlItems` with an optional base URL for links)
- **Content scope**: `auto` (main content from `<main>`/`<article>`, fallback to body), full `body`, or your own **CSS selector**
- Strips **nav, header, footer, aside, forms, cookie/consent banners**, hidden elements, scripts and styles (toggleable, plus your own `removeSelectors`)
- **GFM tables** (pipe tables, even when the source has no header row), fenced code blocks, ATX headings, lists, blockquotes
- **Absolute links and image URLs**, lazy-loaded images resolved (`data-src`, `srcset`)
- Optional **YAML frontmatter** (title, url, description, lang)
- **Token estimate**, word and character counts
- Optional **heading-aware chunks** (`chunkSize`) for embeddings / RAG
- Optional cleaned HTML

How it differs from our [Article Extractor](https://apify.com/dataforgehq/article-extractor): that one uses Readability to keep only the article body of news/blog posts. This converter handles **any page** (docs, product pages, landing pages, wikis, tables) and gives you control over what is kept.

### Input

```json
{
  "urls": ["https://en.wikipedia.org/wiki/Markdown", "https://docs.apify.com/platform"],
  "contentScope": "auto",
  "frontmatter": true,
  "chunkSize": 2000
}
```

Raw HTML: `"htmlItems": [{ "html": "<h1>Hi</h1><p>…</p>", "url": "https://example.com/page", "id": "doc-1" }]`

### Output (one item per page)

```json
{
  "url": "https://en.wikipedia.org/wiki/Markdown",
  "title": "Markdown - Wikipedia",
  "lang": "en",
  "markdown": "---\ntitle: \"Markdown - Wikipedia\"\n…\n---\n\n| Markdown |\n| --- |\n| Filename extensions | `.md`, `.markdown` |…",
  "wordCount": 3690,
  "charCount": 51234,
  "tokenEstimate": 12809,
  "chunkCount": 32,
  "chunks": [{ "index": 0, "heading": "History", "chars": 1980, "text": "## History\n\n…" }]
}
```

### Pricing

**$0.0005 per page converted** ($0.50 per 1,000 pages) + a tiny start fee. HTTP errors, non-HTML responses and empty pages are **free**.

### Limits

Pages that render their content only with JavaScript (single-page apps) may return little text. For those, use our [Website Screenshot](https://apify.com/dataforgehq/website-screenshot) or [URL to PDF](https://apify.com/dataforgehq/url-to-pdf) Actors.

### Related Actors

- [Article Extractor](https://apify.com/dataforgehq/article-extractor)
- [Sitemap URL Extractor](https://apify.com/dataforgehq/sitemap-urls) – get every URL of a site, then convert them here
- [Website Metadata Extractor](https://apify.com/dataforgehq/website-metadata-extractor)
- [PDF Text Extractor](https://apify.com/dataforgehq/pdf-text-extractor)

# Actor input Schema

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

Web pages to convert, one per line. Redirects are followed.

## `htmlItems` (type: `array`):

Convert HTML you already have: \[{"html": "<h1>Hi</h1>", "url": "https://base.url/for/links", "id": "my-id"}]. url and id are optional.

## `contentScope` (type: `string`):

Which part of the page to convert.

## `selector` (type: `string`):

Used when Content scope = selector, e.g. "#content" or ".post-body".

## `removeBoilerplate` (type: `boolean`):

Strip navigation, header, footer, aside, forms, cookie/consent banners and hidden elements before converting.

## `removeSelectors` (type: `array`):

Additional CSS selectors to delete before converting (e.g. ".ads", "#comments").

## `keepImages` (type: `boolean`):

Keep ![alt](src) image references (absolute URLs).

## `keepLinks` (type: `boolean`):

Keep [text](href) links (absolute URLs). Off = plain link text.

## `frontmatter` (type: `boolean`):

Prepend --- title / url / description / lang --- to the Markdown.

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

Also split the Markdown into heading-aware chunks of about this many characters for RAG / embeddings.

## `includeHtml` (type: `boolean`):

Also return the cleaned HTML that was converted.

## `timeoutSecs` (type: `integer`):

Seconds to wait for each page.

## `concurrency` (type: `integer`):

Pages fetched at once.

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

Convert at most this many (0 = all).

## Actor input object example

```json
{
  "urls": [
    "https://en.wikipedia.org/wiki/Markdown",
    "https://example.com"
  ],
  "htmlItems": [],
  "contentScope": "auto",
  "removeBoilerplate": true,
  "removeSelectors": [],
  "keepImages": true,
  "keepLinks": true,
  "frontmatter": false,
  "chunkSize": 0,
  "includeHtml": false,
  "timeoutSecs": 30,
  "concurrency": 8,
  "maxPages": 0
}
```

# Actor output Schema

## `overview` (type: `string`):

All pages (overview table).

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

Counts.

# 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",
        "https://example.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dataforgehq/html-to-markdown-converter").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",
        "https://example.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("dataforgehq/html-to-markdown-converter").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",
    "https://example.com"
  ]
}' |
apify call dataforgehq/html-to-markdown-converter --silent --output-dataset

```

## MCP server setup

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

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/yWBEIcBXqaymfvQmV/builds/LB5Ia3zUndowtVBx8/openapi.json
