其他能力 · 中文选型解读

markitdown

已解读GitHubMITPython

这是微软AutoGen团队推出的Python工具,可将PDF、Office文档、音视频等多类文件转换为Markdown格式,适配大语言模型的文本处理需求。

182.1kstar2 天前更新维护状态MIT · 可评估商用商用提醒
在 GitHub 查看官方项目
适合解决提供特定场景下的 AI 或开发能力
更适合已有明确需求、愿意进一步验证的团队
投入判断上手门槛:需评估。建议先核对项目说明、维护状态与许可
一分钟看懂

这个项目值得继续研究吗?

AI 依据上游资料解读 · 2026/9/4

这是微软AutoGen团队推出的Python工具,可将PDF、Office文档、音视频等多类文件转换为Markdown格式,适配大语言模型的文本处理需求。

解决什么问题
企业做RAG(检索增强生成,一种让大模型基于自有资料回答问题的技术)、文档分析时,多格式零散文件无法直接输入大模型,人工转格式效率低,还易丢失标题、表格等关键结构,影响大模型处理准确率。
适合什么团队
适合需要批量处理多格式文件、搭建大模型知识库、开展非结构化文档内容分析的企业业务、运营及AI落地团队使用。
使用前注意
部署需Python 3.10及以上环境,不可信运行环境需先做输入校验;使用OCR插件、对接Azure相关服务会产生额外API调用成本,插件默认关闭。

本页用于缩短初步筛选时间,不构成技术、采购或法律结论。 正式使用前请在真实业务数据上验证,并以官方说明与许可证为准。

项目导读

从官方资料看清能力、部署与采用边界

AI 翻译整理 · 保留官方来源

以下内容依据项目公开 README 或模型卡翻译整理,代码、命令和产品名保持原样。

项目定位

MarkItDown是微软AutoGen团队开发的轻量型文件转换工具,核心目标是将各类非结构化、半结构化文件转换为Markdown格式,输出内容优先适配大语言模型(LLM,即ChatGPT这类生成式AI模型)及相关文本分析流程,而非面向人工使用的高保真文档转换。和同类工具相比,它重点保留文档的标题、列表、表格、链接等核心结构信息,确保大模型可以准确理解文件内容逻辑。

核心支持能力

可转换的文件格式

目前支持转换的来源格式包括:PDF、Word、Excel、PowerPoint、图片、音频、HTML、CSV/JSON/XML等文本格式、ZIP压缩包、YouTube链接、EPub电子书等,可覆盖企业绝大多数常见文档类型。

转Markdown的价值

Markdown仅含极少量格式标记,接近纯文本的同时可清晰表达文档结构。主流大语言模型普遍在训练阶段学习过大量Markdown内容,对该格式的理解准确率更高,且Markdown的Token(大语言模型的计算单位)利用效率更高,可降低大模型调用成本。

扩展能力

工具支持按需安装可选依赖,不需要全量安装所有格式的转换组件,比如仅需处理PDF、Word、PowerPoint文件,可单独安装对应依赖,减少环境冲突。同时支持第三方插件扩展能力,比如官方提供的markitdown-ocr插件,可对接大语言模型视觉能力,提取文档内嵌图片中的文本内容,无需额外安装机器学习类依赖。

此外还支持对接两类微软Azure云服务,可满足更高阶的转换需求,三者的差异如下: | 能力项 | 内置转换器 | Azure文档智能 | Azure内容理解 | |--------|------------|--------------|--------------| | 转换方式 | 离线、按格式单独提取 | 云端布局提取 | 云端多模态提取 | | 结构化字段提取 | 不支持 | 当前集成未开放 | 可输出YAML格式的结构化字段 | | 自定义分析规则 | 不支持 | 当前集成不可配置 | 支持自定义分析器 | | 音视频支持 | 仅基础音频转录,无视频支持 | 不支持 | 支持音频、视频内容处理 | | 成本 | 仅消耗本地计算资源 | 按Azure API调用量付费 | 按Azure API调用量付费 |

典型使用方式

工具同时支持命令行调用和Python API调用两种模式,业务团队可根据自身使用场景选择:

  1. 命令行调用:无需写代码,仅需一行命令即可完成文件转换,适合小批量零散文件转换场景,示例命令:markitdown 待转换文件.pdf -o 输出文件.md,也支持管道输入、指定输出路径等操作。
  2. Python API调用:可嵌入企业自有业务系统、知识库搭建流程中,适合大批量自动化转换场景,仅需几行代码即可完成调用。

如果需要更高精度的转换、结构化字段提取或者音视频内容处理,可对接Azure内容理解服务,比如可自定义发票分析器,自动提取发票中的供应商名称、开票日期、金额等结构化字段,直接输出到Markdown的头部信息中,无需后续人工整理。

部署与配置要求

运行该工具需要Python 3.10及以上版本,官方推荐使用虚拟环境安装,避免和其他业务系统的依赖产生冲突。标准Python环境、uv、Anaconda均可创建对应的虚拟环境,操作流程简单。

安装时可按需选择依赖包,比如仅需处理PDF和Word文件,可安装markitdown[pdf, docx],不需要安装全量依赖,降低环境维护成本。插件默认关闭,需要主动开启后才可使用,可通过命令行参数或者Python初始化参数开启插件能力。

许可证与采用建议

该项目使用MIT许可证,企业可免费商用,无授权限制。采用建议如下:

  1. 如果是小批量离线转换常规电子文档,对转换精度要求不高,建议使用内置转换器,无额外成本,部署简单。
  2. 如果需要处理扫描版PDF、复杂格式表格,建议对接Azure文档智能服务,提升转换准确率。
  3. 如果需要处理音视频内容、提取结构化业务字段(如合同关键条款、发票信息等),建议对接Azure内容理解服务,可大幅减少后续人工整理工作量。
  4. 不可信运行环境下需要先对输入文件做校验,避免工具越权访问非授权资源。
可核对的事实层

官方资料与来源

查看来源 →
  • autogen
  • autogen-extension
  • langchain
  • markdown
  • microsoft-office
  • openai
  • pdf
默认分支main
关注仓库576
复刻次数13.1k
开放议题811
近期更新2026/9/3
仓库状态未标记归档
上游部署线索
## Prerequisites
MarkItDown requires Python 3.10 or higher. 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

该片段来自项目 README,仅用于初步判断;实际部署请以官方文档为准。

核对上游原始说明节选

Python tool for converting files and office documents to Markdown.

MarkItDown

PyPI PyPI - Downloads Built by AutoGen Team

[!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., convertstream(), or convertlocal()). See the 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, 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 OCR)
  • Audio (EXIF metadata and speech transcription)
  • HTML
  • Text-based formats (CSV, JSON, XML)
  • ZIP files (iterates over contents)
  • YouTube URLs
  • EPubs
  • ... and more!

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 or higher. 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:

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

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

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:

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:

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

Usage

Command-Line

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

Or use -o to specify the output file:

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

You can also pipe content:

cat path-to-file.pdf | markitdown

Optional Dependencies

MarkItDown has optional dependencies for activating various file formats. Earlier in this document, we installed all optional dependencies with the [all] option. However, you can also install them individually for more control. For example:

pip install 'markitdown[pdf, docx, pptx]'

will install only the dependencies for PDF, DOCX, and PPTX files.

At the moment, the following optional dependencies are available:

  • [all] Installs all optional dependencies
  • [pptx] Installs dependencies for PowerPoint files
  • [docx] Installs dependencies for Word files
  • [xlsx] Installs dependencies for Excel files
  • [xls] Installs dependencies for older Excel files
  • [pdf] Installs dependencies for PDF files
  • [outlook] Installs dependencies for Outlook messages
  • [az-doc-intel] Installs dependencies for Azure Document Intelligence
  • [az-content-understanding] Installs dependencies for Azure Content Understanding
  • [audio-transcription] Installs dependencies for audio transcription of wav and mp3 files
  • [youtube-transcription] Installs dependencies for fetching YouTube video transcription

Plugins

MarkItDown also supports 3rd-party plugins. Plugins are disabled by default. To list installed plugins:

markitdown --list-plugins

To enable plugins use:

markitdown --use-plugins path-to-file.pdf

To find available plugins, search GitHub for the hashtag #markitdown-plugin. To develop a plugin, see packages/markitdown-sample-plugin.

markitdown-ocr Plugin

The markitdown-ocr plugin adds OCR support to PDF, DOCX, PPTX, and XLSX converters, extracting text from embedded images using LLM Vision — the same llmclient / llmmodel pattern that MarkItDown already uses for image descriptions. No new ML libraries or binary dependencies required.

Installation:

pip install markitdown-ocr
pip install openai  # or any OpenAI-compatible client

Usage:

Pass the same llmclient and llmmodel you would use for image descriptions:

from markitdown import MarkItDown
from openai import OpenAI

md = MarkItDown(
    enable_plugins=True,
    llm_client=OpenAI(),
    llm_model="gpt-4o",
)
result = md.convert("document_with_images.pdf")
print(result.markdown)

If no llmclient is provided the plugin still loads, but OCR is silently skipped and the standard built-in converter is used instead.

See packages/markitdown-ocr/README.md for detailed documentation.

Azure Content Understanding

Azure Content Understanding provides higher-quality conversion with structured field extraction (YAML front matter), multi-modal support (documents, images, audio, video), and configurable analyzers.

Install: pip install 'markitdown[az-content-understanding]'

When to use Content Understanding

Content Understanding is ideal when you need capabilities beyond what built-in or Document Intelligence converters provide:

  • Audio and video files — CU is the only option for video, and the higher-quality cloud option for audio. Built-in converters have no video support and only basic audio transcription.
  • Structured field extraction — Prebuilt or custom-built analyzers extract domain-specific fields (invoice amounts, receipt dates, contract clauses) serialized as YAML front matter. Neither built-in nor Doc Intel integration exposes fields.
  • Higher-quality document extraction — Cloud-based layout analysis and OCR for scanned PDFs, complex tables, and multi-page documents.
  • Single API for all modalities — One cuendpoint handles documents, images, audio, and video with automatic analyzer routing.

| Capability | Built-in converters | Azure Document Intelligence | Azure Content Understanding | |------------|---------------------|-----------------------------|-----------------------------| | Document conversion | Offline, format-specific extraction | Cloud layout extraction | Cloud multimodal extraction | | Structured fields | Not available | Not exposed by this integration | YAML front matter from analyzer fields | | Custom analyzers | Not available | Not configurable in this integration | Supported with cuanalyzerid | | Audio and video | Basic audio, no video | Not supported | Audio and video analyzers | | Cost | Local compute only | Billable Azure API calls | Billable Azure API calls |

CLI:

markitdown path-to-file.pdf --use-cu --cu-endpoint "<content_understanding_endpoint>"

The endpoint can also be set once in the environment, so callers only need --use-cu:

export MARKITDOWN_CU_ENDPOINT="<content_understanding_endpoint>"
markitdown path-to-file.pdf --use-cu

Python API:

from markitdown import MarkItDown

# Zero-config — auto-selects analyzer per file type
md = MarkItDown(cu_endpoint="<content_understanding_endpoint>")
result = md.convert("report.pdf")   # documents → prebuilt-documentSearch
result = md.convert("meeting.mp4")  # video → prebuilt-videoSearch
result = md.convert("call.wav")     # audio → prebuilt-audioSearch
print(result.markdown)

With a custom analyzer (for domain-specific field extraction):

md = MarkItDown(
    cu_endpoint="<content_understanding_endpoint>",
    cu_analyzer_id="my-invoice-analyzer",
)
result = md.convert("invoice.pdf")
print(result.markdown)
# Output includes YAML front matter with extracted fields:
# ---
# contentType: document
# fields:
#   VendorName: CONTOSO LTD.
#   InvoiceDate: '2019-11-15'
# ---
# <!-- page 1 -->
# ...

When cuanalyzerid is set, the converter automatically scopes it to compatible file types based on the analyzer's modality. Incompatible types (e.g., audio files with a document analyzer) auto-route to default prebuilt analyzers.

Cost note: Each convert() call for a CU-routed format is a billable Azure API call. Use cufiletypes to restrict which formats route to CU:

from markitdown.converters import ContentUnderstandingFileType

md = MarkItDown(
    cu_endpoint="<content_understanding_endpoint>",
    cu_file_types=[ContentUnderstandingFileType.PDF],  # only PDFs use CU
)

More information about Azure Content Understanding can be found here.

Azure Document Intelligence

To use Microsoft Document Intelligence for conversion:

markitdown path-to-file.pdf -o document.md -d -e "<document_intelligence_endpoint>"

The endpoint can also be set once in the environment, so callers only need -d:

export MARKITDOWN_DOCINTEL_ENDPOINT="<document_intelligence_endpoint>"
markitdown path-to-file.pdf -o document.md -d

More information about how to set up an Azure Document Intelligence Resource can be found here

Python API

Basic usage in Python:

from markitdown import MarkItDown

md = MarkItDown(enable_plugins=False) # Set to True to enable plugins
result = md.convert("test.xlsx")
print(result.markdown)

Document Intelligence conversion in Python:

from markitdown import MarkItDown

md = MarkItDown(docintel_endpoint="<document_intelligence_endpoint>")
result = md.convert("test.pdf")
print(result.markdown)

To use Large Language Models for image descriptions (curren