# Html To Markdown Converter 📄 (`powerful_bachelor/html-to-markdown-converter`) Actor

📄✨ HTML to Markdown Converter transforms web pages into clean, portable Markdown. Simply input a URL to extract content while preserving structure, formatting, and media elements.🔄 Perfect for content repurposing, documentation, and creating readable, platform-independent text from any webpage! 🚀

- **URL**: https://apify.com/powerful_bachelor/html-to-markdown-converter.md
- **Developed by:** [Powerful Bachelor](https://apify.com/powerful_bachelor) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 50 total users, 0 monthly users, 95.2% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.70 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

[![Actor status](https://apify.com/actor-badge?actor=powerful_bachelor/html-to-md-conversion)](https://apify.com/powerful_bachelor/html-to-md-conversion)

The HTML to Markdown Converter is a powerful tool that transforms any HTML webpage into clean, well-formatted Markdown. Simply provide the URL of the webpage you want to convert, and this actor will extract the content, process it intelligently, and deliver a polished Markdown file that preserves the structure and meaning of the original content.

### 🔄 Markdown Conversion Features

The HTML to Markdown Converter handles various HTML elements with specialized rules:

- **Headings**: Converts h1-h6 tags to equivalent Markdown headings
- **Lists**: Preserves ordered and unordered lists with proper formatting
- **Tables**: Maintains table structure with column alignment
- **Code Blocks**: Preserves code blocks with language syntax highlighting
- **Images**: Converts images with alt text and absolute URLs
- **Links**: Ensures all links are properly formatted with absolute URLs
- **Emphasis**: Preserves bold, italic, and other text formatting
- **Blockquotes**: Maintains blockquote formatting
- **Media Elements**: Creates Markdown-friendly references for videos, audio, and other media
- **Interactive Elements**: Provides descriptive text for forms, buttons, and other interactive components

### 🤔 Why convert HTML to Markdown?

Converting HTML to Markdown offers numerous benefits:

- 📝 **Simplicity**: Transform complex HTML into clean, readable text
- 🔄 **Portability**: Use the content across different platforms and tools
- 📊 **Content Focus**: Strip away unnecessary styling and scripts
- 🖋️ **Easy Editing**: Modify content in any text editor without HTML knowledge
- 📚 **Documentation**: Create documentation from existing web content
- 📱 **Accessibility**: Improve content readability for screen readers and assistive technologies

### 🚀 Main Features

HTML to Markdown Converter includes powerful features to ensure high-quality conversions:

- **Smart Content Extraction**: Automatically identifies and extracts the main content from webpages
- **Relative URL Resolution**: Converts all relative URLs to absolute URLs for proper linking
- **Table Support**: Preserves table structures with proper Markdown formatting
- **Code Block Preservation**: Maintains code blocks with language syntax highlighting
- **Image Handling**: Converts images with proper alt text and source URLs
- **Video & Media Embedding**: Creates Markdown-friendly references for videos and embedded content
- **Interactive Element Conversion**: Transforms buttons, forms, and other interactive elements
- **Social Media Embed Handling**: Properly references social media posts from platforms like Twitter/X, Instagram, etc.
- **Custom Styling Rules**: Applies consistent formatting for headings, lists, emphasis, and more

### 🛠️ How to use the HTML to Markdown Converter

Using the HTML to Markdown Converter is straightforward:

1. 🔑 Create a free Apify account (if you don't have one)
2. 🔍 Open the HTML to Markdown Converter actor
3. ✏️ Enter the URL(s) of the webpage(s) you want to convert
4. 🚀 Click "Save & Start" and wait for the conversion to complete
5. 💾 Download your Markdown files or access them via the provided links

### 📈 How many pages can you convert?

The converter can process multiple pages in a single run. The number of pages you can convert depends on your Apify subscription plan and the complexity of the webpages. For large-scale conversion projects, consider using a higher-tier plan.

### ⚖️ Is it legal to convert webpages to Markdown?

The converter only processes publicly available content and transforms it into a different format. However, be mindful of copyright restrictions when using the converted content, especially for commercial purposes. Always respect the original content's terms of use and attribution requirements.

### 📝 Input parameters

The actor accepts a JSON array of objects, each containing a `url` property.

Example input:

```json
{
    "startUrls": [
        {
            "url": "https://example.com/page-to-convert"
        },
        {
            "url": "https://another-example.com/another-page"
        }
    ]
}
```

### Output Example

The actor provides detailed information about each processed URL:

````json
{
"url": "https://example.com/page-to-convert",
"markdown": "https://api.apify.com/v2/key-value-stores/markdown-store/records/example.com.md",
"title": "Example Page Title",
"fileName": "example.com.md",
"htmlLength": 45678,
"markdownLength": 12345,
"error": null,
"success": true,
"processedAt": "2023-09-15T14:25:30.000Z"
}```
````

### 🚀 Unlock Content Flexibility

HTML to Markdown Converter is an essential tool for content creators, developers, and anyone who needs to repurpose web content. Whether you're creating documentation, preparing content for a CMS, or archiving web pages in a more readable format, this converter offers a comprehensive and efficient solution. If you have any feedback or run into issues, please don't hesitate to reach out through the Actor's Issues tab in the Apify Console. Happy converting! 🎉

# Actor input Schema

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

URLs of HTML pages to convert to Markdown

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://blog.apify.com/how-to-build-an-ai-agent/"
    }
  ]
}
```

# Actor output Schema

## `results` (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 = {
    "startUrls": [
        {
            "url": "https://blog.apify.com/how-to-build-an-ai-agent/"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("powerful_bachelor/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 = { "startUrls": [{ "url": "https://blog.apify.com/how-to-build-an-ai-agent/" }] }

# Run the Actor and wait for it to finish
run = client.actor("powerful_bachelor/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 '{
  "startUrls": [
    {
      "url": "https://blog.apify.com/how-to-build-an-ai-agent/"
    }
  ]
}' |
apify call powerful_bachelor/html-to-markdown-converter --silent --output-dataset

```

## MCP server setup

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