npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kabeep/fetch-html-to-md

v0.1.0

Published

Convert remote or local HTML resources to Markdown via CLI or Node.js API

Readme

通过 CLI 或 Node.js API 将远程或本地 HTML 资源转换为 Markdown。

NodeJS Version NPM License

English | 简体中文

📖 简介

fetch-html-to-md 是一个轻量级、高性能的 Node.js 解决方案, 旨在弥合网页内容与结构化 Markdown 之间的鸿沟。它设计灵活, 既可以作为开发者友好的 SDK 无缝运行,也可以作为直观的命令行工具使用。

快速开始

npx @kabeep/fetch-html-to-md@latest https://example.com

MCP 服务

npx @kabeep/fetch-html-to-md@latest mcp

📦 安装

作为 Node.js API

npm install @kabeep/fetch-html-to-md --save
yarn add @kabeep/fetch-html-to-md
pnpm add @kabeep/fetch-html-to-md

作为 CLI

npm install --global @kabeep/fetch-html-to-md

⚙️ 用法

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

转换本地文件

fetch-html-to-md ./docs/index.html

转换远程 URL

fetch-html-to-md https://example.com

传入原始 HTML 字符串进行转换

fetch-html-to-md --raw "<strong><em>strong and italic</em></strong>"

从标准输入读取

echo https://example.com | fetch-html-to-md

使用选项

fetch-html-to-md ./index.html --skip-tags div section --alias-tags "figure=p"

🔩 CLI 选项

输入选项

注意:输入标志互斥。每次执行只能提供一个输入源。

| 选项 | 简写 | 类型 | 描述 | |:-------------|:----:|:---------:|:-----------------------------------| | [uri] | - | string | 位置参数。本地 HTML 文件路径或远程 URL。 | | --url | - | string | 指定一个 HTML 页面 URL。 | | --filepath | -f | string | 指定一个本地 HTML 文件路径。 | | --raw | - | boolean | 直接传入原始 HTML 字符串进行转换,而不是使用 [uri]。 |

配置选项

更多信息: https://github.com/stonehank/html-to-md/blob/HEAD/README-EN.md#configoptional

| 选项 | 类型 | 默认值 | 描述 | |:-----------------------|:---------:|:--------:|:-----------------------------------------------------------------------| | --skip-tags | array | (内置) | 跳过渲染的标签,同时保留其内部内容不变。(以空格分隔的列表) | | --empty-tags | array | [] | 要跳过的标签及其内部所有内容。 | | --ignore-tags | array | (内置) | 要完全忽略的标签(包括标签和内容)。 | | --alias-tags | array | - | 使用 key=value 对重命名 HTML 标签。(例如:--alias-tags figure=p dd=p) | | --render-custom-tags | enum | 'true' | 非标准 HTML 标签的规则。选项:'true''false''SKIP''EMPTY''IGNORE' | | --force | boolean | false | 强制自定义配置覆盖原生默认值。 |

通用选项

| 选项 | 简写 | 描述 | |:------------|:----:|:-------------| | --help | -h | 显示帮助菜单和命令选项。 | | --version | -v | 显示包版本。 |

🔌 MCP 服务

fetch-html-to-md CLI 支持 MCP 协议,允许 Claude DesktopCursorWindsurf 等 Agent 客户端在后台直接将其作为工具调用,实现无缝的网页与本地 HTML 抓取转换。

1. 配置客户端

在客户端配置文件(例如 claude_desktop_config.json.cursor/mcp.json)中添加以下配置:

{
    "mcpServers": {
        "fetch-html-to-md": {
            "command": "npx",
            "args": [
                "-y",
                "@kabeep/fetch-html-to-md",
                "mcp"
            ]
        }
    }
}

2. Tool 规格

MCP 服务默认向 Agent 注册名为 fetch_html_to_md 的工具,支持以下参数:

| 参数 | 类型 | 必填 | 说明 | |:------|:---------|:-----:|:----------------------------------------------| | uri | string | | 目标网页 URL(http://https://)或本地 HTML 文件路径 |


💬 Agent 对话示例

配置完成后,你可以直接在 Claude 或 Cursor 中说:

“帮我用 fetch_html_to_md 抓取 https://example.com 的内容,并帮我总结要点。”

💐 致谢

  • html-to-md - 一个用于将 HTML 字符串转换为 markdown 字符串的 JS 库,gzip 压缩后 10kb。

🤝 贡献

欢迎通过 Pull Requests 或 Issues 进行贡献。

📄 许可

本项目基于 MIT 许可授权,详情请参阅 LICENSE 文件。