Back to skills
SKILL.md
Markitdown Win
ASecurityConvert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.
- 97 stars
- 0 votes
- 0 copies
- 3 views
- Added November 8, 2026
Works with
Security analysis
92/100- Installs packages at runtime which could introduce malicious dependencies
Pro scans all 10 files and shows the line behind each finding
npx -y skills add ahang1598/doubao-workbuddy-qwenwork-skills --skill markitdown-win --agent claude-codeAre you the author of Markitdown Win?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ahang1598-markitdown-win)---
name: markitdown-win
description: Convert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.
allowed-tools: Read Write Edit Bash
license: MIT license
metadata:
skill-author: K-Dense Inc.
post_process: aigc-marker-win
---
# MarkItDown - File to Markdown Conversion
## Overview
MarkItDown is a Python tool developed by Microsoft for converting various file formats to Markdown. It's particularly useful for converting documents into LLM-friendly text format, as Markdown is token-efficient and well-understood by modern language models.
**Key Benefits**:
- Convert documents to clean, structured Markdown
- Token-efficient format for LLM processing
- Supports 15+ file formats
- Optional AI-enhanced image descriptions
- OCR for images and scanned documents
- Speech transcription for audio files
## Visual Enhancement with Scientific Schematics
**When creating documents with this skill, always consider adding scientific diagrams and schematics to enhance visual communication.**
If your document does not already contain schematics or diagrams:
- Use the **scientific-schematics** skill to generate AI-powered publication-quality diagrams
- Simply describe your desired diagram in natural language
- Nano Banana Pro will automatically generate, review, and refine the schematic
**For new documents:** Scientific schematics should be generated by default to visually represent key concepts, workflows, architectures, or relationships described in the text.
**How to generate schematics:**
```bash
python scripts/generate_schematic.py "your diagram description" -o figures/output.png
```
The AI will automatically:
- Create publication-quality images with proper formatting
- Review and refine through multiple iterations
- Ensure accessibility (colorblind-friendly, high contrast)
- Save outputs in the figures/ directory
**When to add schematics:**
- Document conversion workflow diagrams
- File format architecture illustrations
- OCR processing pipeline diagrams
- Integration workflow visualizations
- System architecture diagrams
- Data flow diagrams
- Any complex concept that benefits from visualization
For detailed guidance on creating schematics, refer to the scientific-schematics skill documentation.
---
## Supported Formats
| Format | Description | Notes |
| ----------- | ------------------------ | ---------------------------- |
| **PDF** | Portable Document Format | Full text extraction |
| **DOCX** | Microsoft Word | Tables, formatting preserved |
| **PPTX** | PowerPoint | Slides with notes |
| **XLSX** | Excel spreadsheets | Tables and data |
| **Images** | JPEG, PNG, GIF, WebP | EXIF metadata + OCR |
| **Audio** | WAV, MP3 | Metadata + transcription |
| **HTML** | Web pages | Clean conversion |
| **CSV** | Comma-separated values | Table format |
| **JSON** | JSON data | Structured representation |
| **XML** | XML documents | Structured format |
| **ZIP** | Archive files | Iterates contents |
| **EPUB** | E-books | Full text extraction |
| **YouTube** | Video URLs | Fetch transcriptions |
## Quick Start
### Dependencies
小艺 Work 会根据 Skill 根目录的 `requirements.txt` 在后台安装完整格式支持。调用过程中不要执行 `pip install`;若依赖未就绪,等待后台安装完成或在技能页重试。
### Command-Line Usage
Run from the current task workspace and use an absolute output path. Do not `cd` into this Skill. After conversion and AIGC marking, deliver the Markdown file with `send_file_to_user(abs_file_path_list=["<absolute output.md path>"])`.
```bash
# Basic conversion
markitdown document.pdf -o "$PWD/output.md"
# Specify output file
markitdown document.pdf -o "$PWD/output.md"
# Pipe content
cat document.pdf | markitdown > output.md
# Enable plugins
markitdown --list-plugins # List available plugins
markitdown --use-plugins document.pdf -o output.md
```
### Python API
```python
from markitdown import MarkItDown
# Basic usage
md = MarkItDown()
result = md.convert("document.pdf")
print(result.text_content)
# Convert from stream
with open("document.pdf", "rb") as f:
result = md.convert_stream(f, file_extension=".pdf")
print(result.text_content)
```
> **⚠️ 强制合规要求**:根据相关法规要求,所有由 AI 生成或编辑的文档必须添加 AIGC 标识。
**AIGC 合规处理(必须执行)**:
当输出 Markdown 文件时,保存后立即调用 aigc-marker-win:
```python
with open("output.md", "w") as f:
f.write(result.text_content)
```
然后**务必**调用:
```
使用 aigc-marker-win 为 output.md 添加 AIGC 标识
```
**合规检查清单**:
- [ ] Markdown 文件已成功保存
- [ ] 已调用 aigc-marker-win 添加 AIGC 标识
- [ ] 确认标识已正确添加到文档中
## Advanced Features
### 1. AI-Enhanced Image Descriptions
Use LLMs via OpenRouter to generate detailed image descriptions (for PPTX and image files):
```python
from markitdown import MarkItDown
from openai import OpenAI
# Initialize OpenRouter client (OpenAI-compatible API)
client = OpenAI(
api_key="your-openrouter-api-key",
base_url="https://openrouter.ai/api/v1"
)
md = MarkItDown(
llm_client=client,
llm_model="anthropic/claude-opus-4.5", # recommended for scientific vision
llm_prompt="Describe this image in detail for scientific documentation"
)
result = md.convert("presentation.pptx")
print(result.text_content)
```
### 2. Azure Document Intelligence
For enhanced PDF conversion with Microsoft Document Intelligence:
```bash
# Command line
markitdown document.pdf -o output.md -d -e "<document_intelligence_endpoint>"
```
```python
# Python API
from markitdown import MarkItDown
md = MarkItDown(docintel_endpoint="<document_intelligence_endpoint>")
result = md.convert("complex_document.pdf")
print(result.text_content)
```
### 3. Plugin System
MarkItDown supports 3rd-party plugins for extending functionality:
```bash
# List installed plugins
markitdown --list-plugins
# Enable plugins
markitdown --use-plugins file.pdf -o output.md
```
Find plugins on GitHub with hashtag: `#markitdown-plugin`
## DOCX 图片处理(重要)
MarkItDown 会把 DOCX 内嵌图片以 **data URI** 形式写进 Markdown:
``。
**问题**:当图片较大(截图 PNG 通常几 KB ~ 几百 KB)超过 MarkItDown 的内部输出
阈值时,base64 内容会被截断成 `data:image/png;base64...` 占位符,导致图片在
Markdown 阅读器中**无法显示**。此外,即使未截断,内嵌超大 base64 也会让 md 文件
臃肿,且多数阅读器/平台不支持 data URI 图片。
**解决方案**:转换后执行 **DOCX → Markdown 图片后处理**,把占位符替换为从 DOCX
中提取的**独立图片文件**的相对路径引用。
### 使用方法
`scripts/extract_docx_images.py` 依赖 Python 标准库(`zipfile`),无需额外安装
markitdown 即可单独运行:
```bash
# 在 MarkItDown 生成 md 之后执行:
python scripts/extract_docx_images.py 输入.docx 输出.md
# 自定义图片子文件夹名(默认 assets/<文档名>_media/):
python scripts/extract_docx_images.py 输入.docx 输出.md --media-dir 图片
```
`batch_convert.py` 和 `convert_with_ai.py` 已集成:对 `.docx` 输入在写出 markdown
后会自动调用该后处理。
### 工作原理
1. 用 `zipfile` 解析 DOCX:
- 读取 `word/document.xml`,按**文档顺序**提取所有 `r:embed` 的 `rId`;
- 读取 `word/_rels/document.xml.rels`,建立 `rId → media` 文件映射;
- 把 `word/media/` 下对应文件按文档顺序提取到 md 同目录的
`assets/<文档名>_media/`,命名为 `image_01.png`、`image_02.png`…(保留原扩展名)。
2. 把 md 里的 `` 占位符**按位置顺序**逐一替换为
相对路径引用:``。
3. 顺序**严格以 `document.xml` 中 `r:embed` 的真实出现顺序为准**,而不是按文件名
排序,否则会造成图文错位。
### 注意事项
- 转换后图片以**独立文件**保存,需与 `.md` 放在**同一目录**(md 引用的是相对路径),
否则图片无法显示。移动 md 时请连同 `assets/<文档名>_media/` 一起移动。
- **中文文件名/路径编码**:Windows 下请务必用 **UTF-8** 写/读文件(本技能所有脚本
均以 `encoding='utf-8'` 处理 md 与图片路径),避免中文文档名或路径乱码。
### 使用 Python API
```python
from extract_docx_images import postprocess_docx_images
# 对 MarkItDown 生成的 md 执行图片后处理(就地改写 md)
handled, count = postprocess_docx_images("输入.docx", "输出.md")
```
## Optional Dependencies
根目录声明 `markitdown[all]`,由客户端统一准备以下格式支持:
```text
# [all] - All optional dependencies
# [pptx] - PowerPoint files
# [docx] - Word documents
# [xlsx] - Excel spreadsheets
# [xls] - Older Excel files
# [pdf] - PDF documents
# [outlook] - Outlook messages
# [az-doc-intel] - Azure Document Intelligence
# [audio-transcription] - WAV and MP3 transcription
# [youtube-transcription] - YouTube video transcription
```
## Common Use Cases
### 1. Convert Scientific Papers to Markdown
```python
from markitdown import MarkItDown
md = MarkItDown()
# Convert PDF paper
result = md.convert("research_paper.pdf")
with open("paper.md", "w") as f:
f.write(result.text_content)
```
### 2. Extract Data from Excel for Analysis
```python
from markitdown import MarkItDown
md = MarkItDown()
result = md.convert("data.xlsx")
# Result will be in Markdown table format
print(result.text_content)
```
### 3. Process Multiple Documents
```python
from markitdown import MarkItDown
import os
from pathlib import Path
md = MarkItDown()
# Process all PDFs in a directory
pdf_dir = Path("papers/")
output_dir = Path("markdown_output/")
output_dir.mkdir(exist_ok=True)
for pdf_file in pdf_dir.glob("*.pdf"):
result = md.convert(str(pdf_file))
output_file = output_dir / f"{pdf_file.stem}.md"
output_file.write_text(result.text_content)
print(f"Converted: {pdf_file.name}")
```
### 4. Convert PowerPoint with AI Descriptions
```python
from markitdown import MarkItDown
from openai import OpenAI
# Use OpenRouter for access to multiple AI models
client = OpenAI(
api_key="your-openrouter-api-key",
base_url="https://openrouter.ai/api/v1"
)
md = MarkItDown(
llm_client=client,
llm_model="anthropic/claude-opus-4.5", # recommended for presentations
llm_prompt="Describe this slide image in detail, focusing on key visual elements and data"
)
result = md.convert("presentation.pptx")
with open("presentation.md", "w") as f:
f.write(result.text_content)
```
### 5. Batch Convert with Different Formats
```python
from markitdown import MarkItDown
from pathlib import Path
md = MarkItDown()
# Files to convert
files = [
"document.pdf",
"spreadsheet.xlsx",
"presentation.pptx",
"notes.docx"
]
for file in files:
try:
result = md.convert(file)
output = Path(file).stem + ".md"
with open(output, "w") as f:
f.write(result.text_content)
print(f"✓ Converted {file}")
except Exception as e:
print(f"✗ Error converting {file}: {e}")
```
### 6. Extract YouTube Video Transcription
```python
from markitdown import MarkItDown
md = MarkItDown()
# Convert YouTube video to transcript
result = md.convert("https://www.youtube.com/watch?v=VIDEO_ID")
print(result.text_content)
```
## Docker Usage
```bash
# Build image
docker build -t markitdown:latest .
# Run conversion
docker run --rm -i markitdown:latest < ~/document.pdf > output.md
```
## Best Practices
### 1. Choose the Right Conversion Method
- **Simple documents**: Use basic `MarkItDown()`
- **Complex PDFs**: Use Azure Document Intelligence
- **Visual content**: Enable AI image descriptions
- **Scanned documents**: Ensure OCR dependencies are installed
### 2. Handle Errors Gracefully
```python
from markitdown import MarkItDown
md = MarkItDown()
try:
result = md.convert("document.pdf")
print(result.text_content)
except FileNotFoundError:
print("File not found")
except Exception as e:
print(f"Conversion error: {e}")
```
### 3. Process Large Files Efficiently
```python
from markitdown import MarkItDown
md = MarkItDown()
# For large files, use streaming
with open("large_file.pdf", "rb") as f:
result = md.convert_stream(f, file_extension=".pdf")
# Process in chunks or save directly
with open("output.md", "w") as out:
out.write(result.text_content)
```
### 4. Optimize for Token Efficiency
Markdown output is already token-efficient, but you can:
- Remove excessive whitespace
- Consolidate similar sections
- Strip metadata if not needed
```python
from markitdown import MarkItDown
import re
md = MarkItDown()
result = md.convert("document.pdf")
# Clean up extra whitespace
clean_text = re.sub(r'\n{3,}', '\n\n', result.text_content)
clean_text = clean_text.strip()
print(clean_text)
```
## Integration with Scientific Workflows
### Convert Literature for Review
```python
from markitdown import MarkItDown
from pathlib import Path
md = MarkItDown()
# Convert all papers in literature folder
papers_dir = Path("literature/pdfs")
output_dir = Path("literature/markdown")
output_dir.mkdir(exist_ok=True)
for paper in papers_dir.glob("*.pdf"):
result = md.convert(str(paper))
# Save with metadata
output_file = output_dir / f"{paper.stem}.md"
content = f"# {paper.stem}\n\n"
content += f"**Source**: {paper.name}\n\n"
content += "---\n\n"
content += result.text_content
output_file.write_text(content)
# For AI-enhanced conversion with figures
from openai import OpenAI
client = OpenAI(
api_key="your-openrouter-api-key",
base_url="https://openrouter.ai/api/v1"
)
md_ai = MarkItDown(
llm_client=client,
llm_model="anthropic/claude-opus-4.5",
llm_prompt="Describe scientific figures with technical precision"
)
```
### Extract Tables for Analysis
```python
from markitdown import MarkItDown
import re
md = MarkItDown()
result = md.convert("data_tables.xlsx")
# Markdown tables can be parsed or used directly
print(result.text_content)
```
## Troubleshooting
### Common Issues
1. **Missing dependencies**: Wait for 小艺 Work background installation or retry from the skill page. Do not install packages during a task.
2. **Binary file errors**: Ensure files are opened in binary mode
```python
with open("file.pdf", "rb") as f: # Note the "rb"
result = md.convert_stream(f, file_extension=".pdf")
```
3. **OCR not working**: Install tesseract
```bash
# macOS
brew install tesseract
# Ubuntu
sudo apt-get install tesseract-ocr
```
## Performance Considerations
- **PDF files**: Large PDFs may take time; consider page ranges if supported
- **Image OCR**: OCR processing is CPU-intensive
- **Audio transcription**: Requires additional compute resources
- **AI image descriptions**: Requires API calls (costs may apply)
## Next Steps
- See `references/api_reference.md` for complete API documentation
- Check `references/file_formats.md` for format-specific details
- Review `scripts/batch_convert.py` for automation examples
- Explore `scripts/convert_with_ai.py` for AI-enhanced conversions
- Review `scripts/extract_docx_images.py` for DOCX 图片后处理(占位符 → 相对路径图片)
## Resources
- **MarkItDown GitHub**: https://github.com/microsoft/markitdown
- **PyPI**: https://pypi.org/project/markitdown/
- **OpenRouter**: https://openrouter.ai (for AI-enhanced conversions)
- **OpenRouter API Keys**: https://openrouter.ai/keys
- **OpenRouter Models**: https://openrouter.ai/models
- **MCP Server**: markitdown-mcp (for Claude Desktop integration)
- **Plugin Development**: See `packages/markitdown-sample-plugin`
Files in this skill
- .claw-origin.json
- SKILL.md
- assets/example_usage.md
- references/api_reference.md
- references/file_formats.md
- requirements.txt
- scripts/batch_convert.py
- scripts/convert_literature.py
- scripts/convert_with_ai.py
- scripts/extract_docx_images.py
Attribution
Related skills
View all in tools →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.