登录 注册

markitdown (文档转 Markdown 工具)

去点 Star
效率与办公工具
194,818
Stars
0
Forks
0
Watchers
0
Open Issues
未知
许可证
Python
语言
创建时间
最近更新

项目能做什么

用于将各种文件和 Office 文档转换为 Markdown 格式的 Python 工具。
来源:基于仓库元数据 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

项目简介

MarkItDown 是由微软开源的轻量级 Python 工具,专门用于将各种文件和 Office 文档转换为 Markdown 格式。该项目主要面向大语言模型(LLM)及相关的文本分析处理管道(Pipeline),重点保留文档的关键结构(如标题、列表、表格、链接等)。

官方提示:转换后的内容主要用于文本分析工具或 LLM 解析,若追求高保真供人类阅读的排版转换,该工具可能并非最佳选择。

核心功能

  • 多格式文档转换:支持 PDF、PowerPoint(.pptx)、Word(.docx)、Excel(.xlsx / .xls)、EPub、HTML 等文档格式。
  • 纯文本与结构化数据:支持 CSV、JSON、XML 等基于文本的格式,以及递归解析 ZIP 压缩包内容。
  • 多媒体处理:
  • 图像:提取 EXIF 元数据及生成图片描述(Captioning)。
  • 音频:提取 EXIF 元数据及语音转录(Speech transcription)。
  • YouTube 链接:提取视频转录文本。 (注:图像描述与语音转录依赖网络托管服务)
  • 插件扩展机制:支持第三方插件(默认关闭)。例如 markitdown-ocr 插件可通过 LLM Vision 提取内嵌图像中的文字,无需引入额外的本地机器学习库或二进制依赖。
  • 灵活的调用方式:支持命令行(CLI)、管道输入(Pipeline)以及 Python API 调用。

适合谁用

  • 正在搭建 RAG(检索增强生成)系统、知识库或 LLM 提示词工程,需要将多种异构文档快速标准化为 Markdown 格式的开发者。
  • 需要自动化批量提取文档结构化内容的文本分析工作流。

安装步骤

前置环境

  • Python 版本需在 3.10 至 3.14 之间。建议使用虚拟环境避免依赖冲突。

创建并激活虚拟环境(任选一种):

# 标准 Python
python -m venv .venv
source .venv/bin/activate

# 使用 uv
uv venv --python=3.12 .venv
source .venv/bin/activate
# 注意:使用 uv 时需通过 uv pip install 安装包

# 使用 Anaconda
conda create -n markitdown python=3.12
conda activate markitdown

安装 MarkItDown

可以直接安装包含所有功能的完整版:

pip install 'markitdown[all]'

或者从源码安装:

git clone git@github.com:microsoft/markitdown.git
cd markitdown
pip install -e 'packages/markitdown[all]'

也可以按需安装特定格式依赖:

# 例如仅安装 PDF、Word 和 PPT 相关依赖
pip install 'markitdown[pdf, docx, pptx]'

支持的扩展选项包括:[all], [pptx], [docx], [xlsx], [xls], [pdf], [outlook], [az-doc-intel], [az-content-understanding], [audio-transcription], [youtube-transcription]。

配置说明

1. 命令行(CLI)使用

基础转换与重定向输出:

markitdown path-to-file.pdf > document.md

通过 -o 参数指定输出文件:

markitdown path-to-file.pdf -o document.md

管道模式处理:

cat path-to-file.pdf | markitdown

2. 插件与 OCR 配置(Python API)

MarkItDown 插件默认禁用。如果需要 OCR 等增强功能,可安装插件及相关客户端库:

pip install markitdown-ocr
pip install openai  # 或其他兼容 OpenAI 接口的客户端

在 Python 中配置并启用插件:

from markitdown import MarkItDown
from openai import OpenAI

# 实例化 MarkItDown 并配置模型
md = MarkItDown(
    enable_plugins=True,
    llm_client=OpenAI(),
    llm_model="gpt-4o",
)
result = md.convert("document_with_images.pdf")
print(result.markdown)

命令行中查看与启用插件:

# 列出已安装的插件
markitdown --list-plugins

# 启用插件执行转换
markitdown --use-plugins path-to-file.pdf

(独立配置文件说明:此部分原文未说明,请查看原仓库)

常见问题

  • 独立 FAQ 章节:此部分原文未提供专门的 FAQ 章节,请查看原仓库。
  • 安全与权限提醒(原文特别标注):MarkItDown 的 I/O 操作直接继承当前运行进程的权限。在不可信环境中处理输入时,请务必先做好校验;代码层面建议根据实际场景调用限制更严格的接口(例如 convert_stream() 或 convert_local())。
原始 README 摘录(英文原文,节选前 3000 字符)
# MarkItDown

[![PyPI](https://img.shields.io/pypi/v/markitdown.svg)](https://pypi.org/project/markitdown/)
![PyPI - Downloads](https://img.shields.io/pypi/dd/markitdown)

> [!IMPORTANT]
> MarkItDown performs I/O with the privileges of the current process. Like open() or requests.get(), it will access resources that the process itself can access. Sanitize your inputs in untrusted environments, and call the narrowest `convert_*` function needed for your use case (e.g., `convert_stream()`, or `convert_local()`). See the [Security Considerations](#security-considerations) section of the documentation for more information.

MarkItDown is a lightweight Python utility for converting various files to Markdown for use with LLMs and related text analysis pipelines. To this end, it is most comparable to [textract](https://github.com/deanmalmgren/textract), but with a focus on preserving important document structure and content as Markdown (including: headings, lists, tables, links, etc.) While the output is often reasonably presentable and human-friendly, it is meant to be consumed by text analysis tools -- and may not be the best option for high-fidelity document conversions for human consumption.

MarkItDown currently supports the conversion from:

- PDF
- PowerPoint
- Word
- Excel
- Images (EXIF metadata and captioning)
- Audio (EXIF metadata and speech transcription)
- HTML
- Text-based formats (CSV, JSON, XML)
- ZIP files (iterates over contents)
- YouTube URLs
- EPubs
- ... and more!

NOTE: Image captioning and speech transcription rely on web-hosted services.

## Why Markdown?

Markdown is extremely close to plain text, with minimal markup or formatting, but still
provides a way to represent important document structure. Mainstream LLMs, such as
OpenAI's GPT-4o, natively "_speak_" Markdown, and often incorporate Markdown into their
responses unprompted. This suggests that they have been trained on vast amounts of
Markdown-formatted text, and understand it well. As a side benefit, Markdown conventions
are also highly token-efficient.

## Prerequisites
MarkItDown requires Python 3.10 through 3.14. It is recommended to use a virtual environment to avoid dependency conflicts.

With the standard Python installation, you can create and activate a virtual environment using the following commands:

```bash
python -m venv .venv
source .venv/bin/activate
```

If using `uv`, you can create a virtual environment with:

```bash
uv venv --python=3.12 .venv
source .venv/bin/activate
# NOTE: Be sure to use 'uv pip install' rather than just 'pip install' to install packages in this virtual environment
```

If you are using Anaconda, you can create a virtual environment with:

```bash
conda create -n markitdown python=3.12
conda activate markitdown
```

## Installation

To install MarkItDown, use pip: `pip install 'markitdown[all]'`. Alternatively, you can install it from the source:

```bash
git clone git@github.com:microsoft/markitdown.git
cd markitdown
pip install
阅读完整原文

商业机会分析 规则生成(AI 未配置)

综合评分 45.0 分。该项目在“个人可实施性”维度得 60 分,“付费可能性”维度得 20.0 分,差异化空间 40.0 分(评分依据见评分卡)。

面向细分需求的二次开发产品

产品构想基于 markitdown 的核心能力,聚焦一个更窄的场景(如某平台、某行业)做差异化。
目标用户该细分场景用户
难度/周期中 · 2~6 周
收费模式买断制 / 订阅制 / 广告
竞争风险细分需求规模需验证
依据 AI 推测:基于项目主题标签的判断

封装为在线小工具或 API 服务

产品构想把项目最常用的一个功能做成网页小工具,靠流量变现或按量计费。
目标用户搜索引擎带来的长尾用户
难度/周期低 · 1~3 周
收费模式免费引流 + 增值功能 / API 按量计费
竞争风险同质化竞争,需做好 SEO
依据 AI 推测:基于技术栈与部署特征的判断
以上为规则引擎基于仓库公开数据生成的参考结论,包含推测成分,不构成投资或创业承诺;配置 AI 后可获得更深入的分析。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

项目中文简介Stars语言
alchaincyf/huashu-md-html 中文介绍暂未生成
md/html 双向流水线 · 三个能力一站式:万物→md / md→精美html / html→md。封装 marki
942 CSS
DuanYan007/markitdown 中文介绍暂未生成
markitdown:Cli;Lib; Java
869 Java
magicyuan876/mineru-tianshu 中文介绍暂未生成
天枢 - 企业级 AI 一站式数据预处理平台 | PDF/Office转Markdown | 支持MCP协议AI助手集成
851 Python
ibrahimqureshae/mdflux 中文介绍暂未生成
Turn any document into clean, AI-ready Markdown. Local-first
586 Python
AeternaLabsHQ/pullmd 中文介绍暂未生成
Self-hosted URL- and file-to-Markdown service for humans and
520 JavaScript
shoryasethia/markdrop 中文介绍暂未生成
A Python package for converting PDFs to markdown while extra
210 Python
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 ,最近推送 ,发布过 24 个 Release
社区活跃Star 194,818 / Fork 0 / Issue 0(数据支持,可自行核实)
许可证未检测到(需人工确认)
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

快速开始(以仓库 README 为准)
git clone https://github.com/microsoft/markitdown.git
cd markitdown
# 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
阅读原仓库文档
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。