fetch-html-to-md
Convert remote or local HTML resources to Markdown via CLI or Node.js API.
English | įŽäŊ䏿
đ Introduction
fetch-html-to-md is a lightweight, high-performance Node.js solution designed to bridge the gap between web content and structured Markdown. Built with flexibility in mind, it operates seamlessly both as a developer-friendly SDK and as an intuitive command-line utility.
Quick Start
npx @kabeep/fetch-html-to-md@latest https://example.comMCP Server
npx @kabeep/fetch-html-to-md@latest mcpđĻ Installation
As Node.js API
npm install @kabeep/fetch-html-to-mdAs CLI
npm install --global @kabeep/fetch-html-to-mdâī¸ Usage
ESModule
import fetchHtml2md, {
html2md,
type Html2MdOptions
} from '@kabeep/fetch-html-to-md';
// 1. Facade Function: Automatically converts local file path or remote URL
const markdown = await fetchHtml2md('https://example.com', {
// ...Html2MdOptions
});
// 2. Built-in html-to-md
const rawMarkdown = html2md('<h1>Hello World</h1>');CommonJS
const fetchHtml2md = require('@kabeep/fetch-html-to-md');
const { html2md } = require('@kabeep/fetch-html-to-md');
async function main() {
// 1. Facade Function
const markdown = await fetchHtml2md('./index.html');
console.log(markdown);
// 2. Built-in html-to-md
const rawMarkdown = html2md('<h1>Hello World</h1>');
}CLI
Convert a local file
fetch-html-to-md ./docs/index.htmlConvert a remote URL
fetch-html-to-md https://example.comPass a raw HTML string to convert
fetch-html-to-md --raw "<strong><em>strong and italic</em></strong>"Read from stdin
echo https://example.com | fetch-html-to-mdUse Options
fetch-html-to-md ./index.html --skip-tags div section --alias-tags "figure=p"đŠ CLI Options
Input Options
Note: Input flags are mutually exclusive. Only one input source can be provided per execution.
Option | Short | Type | Description |
| - |
| Positional argument. Path to a local HTML file or a remote URL. |
| - |
| Specify an HTML page URL. |
|
|
| Specify a local HTML file path. |
| - |
| Pass a raw HTML string directly instead of |
Configuration Options
See more: https://github.com/stonehank/html-to-md/blob/HEAD/README-EN.md#configoptional
Option | Type | Default | Description |
|
| (native) | Tags to skip rendering while keeping their inner content intact. (space-separated list) |
|
|
| Tags to skip along with all content inside them. |
|
| (native) | Tags to completely ignore (both tag and content). |
|
| - | Rename HTML tags using |
|
|
| Rule for non-standard HTML tags. Choices: |
|
|
| Force custom configurations to overwrite native defaults. |
General Options
Option | Short | Description |
|
| Display help menu and command options. |
|
| Display package version. |
đ MCP Server
The fetch-html-to-md CLI natively supports the Model Context Protocol (MCP).
This enables AI clients such as Claude Desktop, Cursor, and Windsurf
to seamlessly invoke it as a background tool for web scraping and local HTML
conversion.
1. Client Setup
Add the following snippet to your client configuration file (e.g.,
claude_desktop_config.json or .cursor/mcp.json):
{
"mcpServers": {
"fetch-html-to-md": {
"command": "npx",
"args": [
"-y",
"@kabeep/fetch-html-to-md",
"mcp"
]
}
}
}2. Tool Schema
The MCP server exposes a default tool named fetch_html_to_md with the
following parameters:
Parameter | Type | Required | Description |
|
| Yes | Target webpage URL ( |
đŦ Example Prompt
Once configured, you can simply ask your AI assistant:
"Fetch https://example.com using fetch_html_to_md and summarize the key takeaways."
đ Credits
html-to-md - A JS library for convert HTML<String> to markdown<String>, gzip 10kb.
đ¤ Contribution
Contributions via Pull Requests or Issues are welcome.
đ License
This project is licensed under the MIT License. See the LICENSE file for details.