MarkItDown Skill
Overview
MarkItDown is a lightweight Python utility by Microsoft that converts various file formats into Markdown. It is specifically designed for LLM and text analysis pipelines, preserving document structure such as headings, lists, tables, and links.
This skill enables AI agents to process non-text files by converting them to Markdown, which is the most token-efficient format for LLM consumption.
When to Use This Skill
Use this skill when:
- The user uploads a file that is not plain text (PDF, DOCX, XLSX, PPTX, JPG, PNG, MP3, etc.)
- The user asks to "read", "extract", "analyze", or "summarize" a document, spreadsheet, presentation, or image
- The user wants to convert a file to Markdown format
- The user needs to process multiple files and extract their text content
Supported File Formats
| Format |
Extension |
Notes |
| PDF |
.pdf |
Extracts text, preserves structure |
| Microsoft Word |
.docx, .doc |
Preserves headings, lists, tables |
| Microsoft Excel |
.xlsx, .xls |
Converts sheets to Markdown tables |
| Microsoft PowerPoint |
.pptx |
Extracts slide content |
| Images |
.jpg, .jpeg, .png, .gif, .bmp |
Extracts EXIF metadata and OCR text |
| Audio |
.wav, .mp3 |
Extracts metadata and transcribes speech |
| HTML |
.html, .htm |
Converts to clean Markdown |
| Plain Text |
.csv, .json, .xml, .txt |
Converts with formatting |
| ZIP |
.zip |
Traverses and converts contents |
| YouTube URL |
URL |
Fetches subtitles/transcripts |
| EPub |
.epub |
E-book conversion |
For detailed format information, load references/supported-formats.md.
Prerequisites
Python Version
Installation
Install MarkItDown with all optional dependencies:
pip install 'markitdown[all]'
Or install with specific format support only:
pip install 'markitdown[pdf,docx,xlsx,pptx]'
The bundled script scripts/convert_file.py will automatically check for installation and prompt if missing.
Workflow: Converting a File to Markdown
Step 1: Identify the File and Goal
Determine:
- What file(s) need to be converted?
- What is the target output? (stdout, file, or in-memory string)
- Is OCR or image description needed? (requires LLM client)
Step 2: Convert Using the Script
Basic conversion (output to stdout):
python scripts/convert_file.py path/to/file.pdf
Convert and save to file:
python scripts/convert_file.py path/to/file.pdf -o output.md
Batch convert a directory:
python scripts/batch_convert.py path/to/documents/ -o path/to/output/
Step 3: Use the Markdown Output
The converted Markdown can be:
- Passed directly to the LLM for analysis/summarization
- Saved to disk for later use
- Further processed or split into chunks
Python API Usage
For programmatic integration within the agent's Python environment:
from markitdown import MarkItDown
# Basic conversion
md = MarkItDown()
result = md.convert("document.pdf")
print(result.markdown)
# With LLM for image description (requires OpenAI or compatible client)
from openai import OpenAI
md = MarkItDown(
llm_client=OpenAI(),
llm_model="gpt-4o"
)
result = md.convert("presentation.pptx")
print(result.markdown)
Important Notes
Security
- MarkItDown performs I/O with the same permissions as the current process
- In untrusted environments (e.g., web services), never pass raw user input directly to MarkItDown
- Restrict file paths, URI protocols, and network targets
- Use the narrowest API possible:
- Local files only:
convert_local()
- Custom network requests: fetch with
requests, then convert_response()
- Full control: open stream, then
convert_stream()
LLM Image Description
- To describe images within documents (PDF, PPTX, images), provide an
llm_client
- Without LLM, images are skipped or only EXIF metadata is extracted
- Supported LLM clients: OpenAI-compatible APIs
Azure Integration (Optional)
- Azure Document Intelligence: Enhanced OCR and layout analysis
- Azure Content Understanding: Multi-modal support (documents, images, audio, video)
- Requires Azure endpoint and credentials
- Load
references/integration-guide.md for Azure setup details
Resources
scripts/convert_file.py — Convert a single file to Markdown
scripts/batch_convert.py — Batch convert files in a directory
references/supported-formats.md — Detailed format support and notes
references/integration-guide.md — Integration patterns, Azure setup, plugin usage
1---2name: markitdown-skill3description: Convert various file formats (PDF, Excel, Word, PowerPoint, images, audio, HTML, etc.) to Markdown using Microsoft's MarkItDown tool. This skill should be used when the user uploads a non-text file or asks to extract text/content from documents, spreadsheets, presentations, images, or audio files. It enables AI agents to read and understand file contents by converting them into LLM-friendly Markdown format. Trigger when file conversion to text or markdown is needed.4---56# MarkItDown Skill78## Overview910**MarkItDown** is a lightweight Python utility by Microsoft that converts various file formats into Markdown. It is specifically designed for LLM and text analysis pipelines, preserving document structure such as headings, lists, tables, and links.1112This skill enables AI agents to process non-text files by converting them to Markdown, which is the most token-efficient format for LLM consumption.1314## When to Use This Skill1516Use this skill when:17- The user uploads a file that is not plain text (PDF, DOCX, XLSX, PPTX, JPG, PNG, MP3, etc.)18- The user asks to "read", "extract", "analyze", or "summarize" a document, spreadsheet, presentation, or image19- The user wants to convert a file to Markdown format20- The user needs to process multiple files and extract their text content2122## Supported File Formats2324| Format | Extension | Notes |25|--------|-----------|-------|26| **PDF** | `.pdf` | Extracts text, preserves structure |27| **Microsoft Word** | `.docx`, `.doc` | Preserves headings, lists, tables |28| **Microsoft Excel** | `.xlsx`, `.xls` | Converts sheets to Markdown tables |29| **Microsoft PowerPoint** | `.pptx` | Extracts slide content |30| **Images** | `.jpg`, `.jpeg`, `.png`, `.gif`, `.bmp` | Extracts EXIF metadata and OCR text |31| **Audio** | `.wav`, `.mp3` | Extracts metadata and transcribes speech |32| **HTML** | `.html`, `.htm` | Converts to clean Markdown |33| **Plain Text** | `.csv`, `.json`, `.xml`, `.txt` | Converts with formatting |34| **ZIP** | `.zip` | Traverses and converts contents |35| **YouTube URL** | URL | Fetches subtitles/transcripts |36| **EPub** | `.epub` | E-book conversion |3738For detailed format information, load `references/supported-formats.md`.3940## Prerequisites4142### Python Version43- Python 3.10 or higher4445### Installation4647Install MarkItDown with all optional dependencies:4849```bash50pip install 'markitdown[all]'51```5253Or install with specific format support only:5455```bash56pip install 'markitdown[pdf,docx,xlsx,pptx]'57```5859The bundled script `scripts/convert_file.py` will automatically check for installation and prompt if missing.6061## Workflow: Converting a File to Markdown6263### Step 1: Identify the File and Goal6465Determine:66- What file(s) need to be converted?67- What is the target output? (stdout, file, or in-memory string)68- Is OCR or image description needed? (requires LLM client)6970### Step 2: Convert Using the Script7172**Basic conversion (output to stdout):**73```bash74python scripts/convert_file.py path/to/file.pdf75```7677**Convert and save to file:**78```bash79python scripts/convert_file.py path/to/file.pdf -o output.md80```8182**Batch convert a directory:**83```bash84python scripts/batch_convert.py path/to/documents/ -o path/to/output/85```8687### Step 3: Use the Markdown Output8889The converted Markdown can be:90- Passed directly to the LLM for analysis/summarization91- Saved to disk for later use92- Further processed or split into chunks9394## Python API Usage9596For programmatic integration within the agent's Python environment:9798```python99from markitdown import MarkItDown100101# Basic conversion102md = MarkItDown()103result = md.convert("document.pdf")104print(result.markdown)105106# With LLM for image description (requires OpenAI or compatible client)107from openai import OpenAI108109md = MarkItDown(110 llm_client=OpenAI(),111 llm_model="gpt-4o"112)113result = md.convert("presentation.pptx")114print(result.markdown)115```116117## Important Notes118119### Security120- MarkItDown performs I/O with the same permissions as the current process121- In untrusted environments (e.g., web services), **never** pass raw user input directly to MarkItDown122- Restrict file paths, URI protocols, and network targets123- Use the narrowest API possible:124 - Local files only: `convert_local()`125 - Custom network requests: fetch with `requests`, then `convert_response()`126 - Full control: open stream, then `convert_stream()`127128### LLM Image Description129- To describe images within documents (PDF, PPTX, images), provide an `llm_client`130- Without LLM, images are skipped or only EXIF metadata is extracted131- Supported LLM clients: OpenAI-compatible APIs132133### Azure Integration (Optional)134- Azure Document Intelligence: Enhanced OCR and layout analysis135- Azure Content Understanding: Multi-modal support (documents, images, audio, video)136- Requires Azure endpoint and credentials137- Load `references/integration-guide.md` for Azure setup details138139## Resources140141- `scripts/convert_file.py` — Convert a single file to Markdown142- `scripts/batch_convert.py` — Batch convert files in a directory143- `references/supported-formats.md` — Detailed format support and notes144- `references/integration-guide.md` — Integration patterns, Azure setup, plugin usage