# HTML to Markdown Converter - Bulk Web Content to MD (`santamaria-automations/html-to-markdown`) Actor

Extract main article content from any website and convert to clean Markdown including headings, links, images, tables, and code blocks. Perfect for LLM training, AI pipelines, and documentation. Export data, run via API, schedule and monitor runs, or integrate with other tools.

- **URL**: https://apify.com/santamaria-automations/html-to-markdown.md
- **Developed by:** [Alessandro Santamaria](https://apify.com/santamaria-automations) (community)
- **Categories:** Automation, Integrations, AI
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 url 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## HTML to Markdown Converter - Bulk Web Content to MD

**Convert any website to clean Markdown — perfect for LLM training, AI pipelines, and documentation.**

Give the actor a list of URLs and get back clean, well-formatted Markdown for every page. Tables, code blocks, images, and nested lists are preserved. Navigation bars, footers, cookie banners, sidebars, and ads are stripped out automatically via readability-style main content extraction.

### Features

- **Readability-style extraction** — returns the article body, not the whole page
- **Tables preserved** — HTML tables become proper Markdown tables with pipes and separators
- **Code blocks preserved** — `<pre>` and `<code>` blocks kept intact, fenced and ready for LLMs
- **Images preserved** — alt text, titles, and absolute URLs
- **Nested structures** — lists inside lists, blockquotes, headings all handled correctly
- **Strikethrough** — `<s>`, `<strike>`, `<del>` converted to `~~text~~`
- **Outbound link discovery** — every external link the page points to, with anchor text
- **Smart metadata** — page title, meta description, Open Graph, content type classification
- **Parallel processing** — 6 URLs at a time for fast bulk conversion
- **Tiny footprint** — minimal compute usage keeps your bill low

### Example Output

Input URL: `https://en.wikipedia.org/wiki/Markdown`

```markdown
## Markdown

**Markdown** is a lightweight [markup language](/wiki/Markup_language) for
creating [formatted text](/wiki/Formatting_(word_processing)) using a
[plain-text editor](/wiki/Text_editor). [John Gruber](/wiki/John_Gruber)
created Markdown in 2004 as an easy-to-read markup language.

### Examples

Text using Markdown syntax:

​```
## Heading

Paragraphs are separated
by a blank line.

**bold**, *italic*, `monospace`
​```

Bullet lists nested within numbered list:

1. fruits
   - apple
   - banana
2. vegetables
   - carrot
   - broccoli

### See also

- [CommonMark](/wiki/CommonMark)
- [reStructuredText](/wiki/ReStructuredText)
- [AsciiDoc](/wiki/AsciiDoc)
````

Clean, readable, LLM-ready. No navigation menus, no "Toggle sidebar", no language switcher.

### Input

```json
{
  "urls": [
    "https://en.wikipedia.org/wiki/Markdown",
    "https://blog.apify.com/"
  ],
  "extractMainContent": true,
  "includeImages": true,
  "includeTables": true,
  "includeStrikethrough": true,
  "followRedirects": true,
  "maxContentLengthKB": 500,
  "timeoutSeconds": 30
}
```

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `urls` | array of strings | **required** | URLs to fetch and convert |
| `extractMainContent` | boolean | `true` | Strip navigation, ads, footers — return only article body |
| `includeImages` | boolean | `true` | Keep image links in output |
| `includeTables` | boolean | `true` | Enable table conversion plugin |
| `includeStrikethrough` | boolean | `true` | Enable `~~strikethrough~~` plugin |
| `followRedirects` | boolean | `true` | Follow HTTP 3xx redirects |
| `maxContentLengthKB` | integer | `500` | Per-URL HTML size cap |
| `timeoutSeconds` | integer | `30` | Per-URL download + parse timeout |

### Output

One record per input URL:

```json
{
  "url": "https://en.wikipedia.org/wiki/Markdown",
  "final_url": "https://en.wikipedia.org/wiki/Markdown",
  "success": true,
  "error": "",
  "page_title": "Markdown - Wikipedia",
  "page_description": "Markdown is a lightweight markup language...",
  "markdown": "## Markdown\n\n**Markdown** is a lightweight...",
  "markdown_length": 36278,
  "word_count": 2907,
  "html_length": 195413,
  "content_type": "article",
  "images": [
    "https://upload.wikimedia.org/wikipedia/commons/..."
  ],
  "links": [
    { "text": "John Gruber", "url": "https://daringfireball.net/" }
  ],
  "main_content_only": true,
  "scraped_at": "2026-04-07T12:34:56Z"
}
```

`content_type` is one of: `article`, `blog`, `documentation`, `generic` — detected from JSON-LD schema, `<article>` tags, and code block density.

### Main Content Extraction

When `extractMainContent` is enabled, the actor tries these strategies in order:

1. **JSON-LD `articleBody`** — Schema.org `Article`, `BlogPosting`, or `NewsArticle`
2. **CSS selectors** — `.mw-parser-output`, `.article-content`, `.post-content`, `.entry-content`, `.article-body`, `.post-body`, `#mw-content-text`, `#content`, `#main`
3. **Semantic tags** — `<article>`, `<main>`, `[role=main]`
4. **Body fallback** — `<body>` with navigation, footer, aside, script, style, forms, and common noise classes removed

This gives much cleaner Markdown output for articles and blog posts than a naive conversion of the entire page.

### Use Cases

- **LLM training data** — build high-quality datasets from web content for fine-tuning
- **AI RAG pipelines** — ingest web content into vector DBs (Pinecone, Weaviate, Qdrant) as clean chunks
- **Content archiving** — save articles, blog posts, and documentation as portable Markdown files
- **Documentation conversion** — migrate legacy HTML docs to Markdown-based static site generators
- **Newsletter generation** — extract clean article text for email newsletters without HTML clutter
- **Note-taking workflows** — save web articles directly to Obsidian, Notion, Logseq, or any Markdown tool
- **Research and summarization** — feed AI summarizers with the actual content, not navigation menus
- **Knowledge base construction** — build searchable knowledge bases from public web content
- **Competitor content analysis** — bulk-convert competitor blogs for analysis

### Pricing

Pay-per-event — you only pay for URLs you actually convert:

| Event | Price |
|-------|-------|
| Actor start | $0.001 |
| URL converted | $0.003 |

**1,000 URLs ≈ $3.00**

No hidden platform fees, no surprise compute charges.

### Related Actors

- [RSS Feed Reader](https://apify.com/santamaria-automations/rss-feed-reader) — pull article URLs from RSS feeds, then pipe into this actor
- [PDF Text Extractor](https://apify.com/santamaria-automations/pdf-extractor) — convert PDFs to plain text instead of HTML
- [Website Content Crawler](https://apify.com/apify/website-content-crawler) — crawl entire sites, not just a URL list
- [Website Tech Stack Detector](https://apify.com/santamaria-automations/website-tech-detector) — identify the CMS and tech behind any site

***

Built by [santamaria-automations](https://apify.com/santamaria-automations).

# Actor input Schema

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

List of URLs to download and convert to Markdown. Each URL is processed independently.

## `extractMainContent` (type: `boolean`):

Use readability-style extraction to return only the article body (strips navigation, ads, footers, sidebars). Recommended for articles and blog posts.

## `includeImages` (type: `boolean`):

Preserve image links in the Markdown output and the `images` array.

## `includeTables` (type: `boolean`):

Convert HTML tables to Markdown table syntax with pipes and separators.

## `includeStrikethrough` (type: `boolean`):

Convert <s>, <strike>, and <del> tags to ~~strikethrough~~ Markdown syntax.

## `followRedirects` (type: `boolean`):

Follow HTTP 3xx redirects. The final URL is returned in `final_url`.

## `maxContentLengthKB` (type: `integer`):

Safety cap on downloaded HTML size per URL. Larger pages are truncated.

## `timeoutSeconds` (type: `integer`):

Per-URL download and parsing timeout.

## `proxyConfiguration` (type: `object`):

Optional proxy for downloading pages from restricted sources.

## Actor input object example

```json
{
  "urls": [
    "https://en.wikipedia.org/wiki/Markdown",
    "https://blog.apify.com/"
  ],
  "extractMainContent": true,
  "includeImages": true,
  "includeTables": true,
  "includeStrikethrough": true,
  "followRedirects": true,
  "maxContentLengthKB": 500,
  "timeoutSeconds": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `conversions` (type: `string`):

Dataset containing one conversion record per input URL

# 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://blog.apify.com/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("santamaria-automations/html-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",
        "https://blog.apify.com/",
    ] }

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

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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://blog.apify.com/"
  ]
}' |
apify call santamaria-automations/html-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=santamaria-automations/html-to-markdown",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "HTML to Markdown Converter - Bulk Web Content to MD",
        "description": "Extract main article content from any website and convert to clean Markdown including headings, links, images, tables, and code blocks. Perfect for LLM training, AI pipelines, and documentation. Export data, run via API, schedule and monitor runs, or integrate with other tools.",
        "version": "1.0",
        "x-build-id": "hzy5wg69trDagGFyd"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/santamaria-automations~html-to-markdown/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-santamaria-automations-html-to-markdown",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/santamaria-automations~html-to-markdown/runs": {
            "post": {
                "operationId": "runs-sync-santamaria-automations-html-to-markdown",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/santamaria-automations~html-to-markdown/run-sync": {
            "post": {
                "operationId": "run-sync-santamaria-automations-html-to-markdown",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "urls"
                ],
                "properties": {
                    "urls": {
                        "title": "URLs",
                        "type": "array",
                        "description": "List of URLs to download and convert to Markdown. Each URL is processed independently.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "extractMainContent": {
                        "title": "Extract Main Content Only",
                        "type": "boolean",
                        "description": "Use readability-style extraction to return only the article body (strips navigation, ads, footers, sidebars). Recommended for articles and blog posts.",
                        "default": true
                    },
                    "includeImages": {
                        "title": "Include Images",
                        "type": "boolean",
                        "description": "Preserve image links in the Markdown output and the `images` array.",
                        "default": true
                    },
                    "includeTables": {
                        "title": "Include Tables",
                        "type": "boolean",
                        "description": "Convert HTML tables to Markdown table syntax with pipes and separators.",
                        "default": true
                    },
                    "includeStrikethrough": {
                        "title": "Include Strikethrough",
                        "type": "boolean",
                        "description": "Convert <s>, <strike>, and <del> tags to ~~strikethrough~~ Markdown syntax.",
                        "default": true
                    },
                    "followRedirects": {
                        "title": "Follow Redirects",
                        "type": "boolean",
                        "description": "Follow HTTP 3xx redirects. The final URL is returned in `final_url`.",
                        "default": true
                    },
                    "maxContentLengthKB": {
                        "title": "Max Content Length (KB)",
                        "minimum": 10,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "Safety cap on downloaded HTML size per URL. Larger pages are truncated.",
                        "default": 500
                    },
                    "timeoutSeconds": {
                        "title": "Timeout (seconds)",
                        "minimum": 5,
                        "maximum": 300,
                        "type": "integer",
                        "description": "Per-URL download and parsing timeout.",
                        "default": 30
                    },
                    "proxyConfiguration": {
                        "title": "Proxy Configuration",
                        "type": "object",
                        "description": "Optional proxy for downloading pages from restricted sources.",
                        "default": {
                            "useApifyProxy": false
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
