1. Project Overview & Quickstart (microsoft/markitdown)
File: README.md
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 narrowestconvert_*function needed for your use case (e.g.,convert_stream(), orconvert_local()). 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:
- 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/activateIf 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 environmentIf you are using Anaconda, you can create a virtual environment with:
conda create -n markitdown python=3.12
conda activate markitdownInstallation
To install MarkItDown, use pip: pip install 'markitdown[all]'. Alternatively, you can install it from the source:
git clone [email protected]:microsoft/markitdown.git
cd markitdown
pip install -e 'packages/markitdown[all]'Usage
Command-Line
markitdown path-to-file.pdf > document.mdOr use -o to specify the output file:
markitdown path-to-file.pdf -o document.mdYou can also pipe content:
cat path-to-file.pdf | markitdownOptional 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-pluginsTo enable plugins use:
markitdown --use-plugins path-to-file.pdfTo 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 llm_client / llm_model 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 clientUsage:
Pass the same llm_client and llm_model 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.text_content)If no llm_client 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
cu_endpointhandles 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 cu_analyzer_id |
| 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>"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'
# ---
#
# ...When cu_analyzer_id 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 cu_file_types 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>"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.text_content)Document Intelligence conversion in Python:
from markitdown import MarkItDown
md = MarkItDown(docintel_endpoint="<document_intelligence_endpoint>")
result = md.convert("test.pdf")
print(result.text_content)To use Large Language Models for image descriptions (currently only for pptx and image files), provide llm_client and llm_model:
from markitdown import MarkItDown
from openai import OpenAI
client = OpenAI()
md = MarkItDown(llm_client=client, llm_model="gpt-4o", llm_prompt="optional custom prompt")
result = md.convert("example.jpg")
print(result.text_content)Docker
docker build -t markitdown:latest .
docker run --rm -i markitdown:latest < ~/your-file.pdf > output.mdContributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct.
For more information see the Code of Conduct FAQ or
contact [email protected] with any additional questions or comments.
How to Contribute
You can help by looking at issues or helping review PRs. Any issue or PR is welcome, but we have also marked some as 'open for contribution' and 'open for reviewing' to help facilitate community contributions. These are of course just suggestions and you are welcome to contribute in any way you like.
Running Tests and Checks
Navigate to the MarkItDown package:
shcd packages/markitdownInstall
hatchin your environment and run tests:shpip install hatch # Other ways of installing hatch: https://hatch.pypa.io/dev/install/ hatch shell hatch test(Alternative) Use the Devcontainer which has all the dependencies installed:
sh# Reopen the project in Devcontainer and run: hatch testRun pre-commit checks before submitting a PR:
pre-commit run --all-files
Security Considerations
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: Do not pass untrusted input directly to MarkItDown. If any part of the input may be controlled by an untrusted user or system, such as in hosted or server-side applications, it must be validated and restricted before calling MarkItDown. Depending on your environment, this may include restricting file paths, limiting URI schemes and network destinations, and blocking access to private, loopback, link-local, or metadata-service addresses.
Call only the conversion method you need: Prefer the narrowest conversion API that fits your use case. MarkItDown's convert() method is intentionally permissive and can handle local files, remote URIs, and byte streams. If your application only needs to read local files, call convert_local() instead. If you need more control over URI fetching, call requests.get() yourself and pass the response object to convert_response(). For maximum control, open a stream to the input you want converted and call convert_stream().
Contributing 3rd-party Plugins
You can also contribute by creating and sharing 3rd party plugins. See packages/markitdown-sample-plugin for more details.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
Microsoft's Trademark & Brand Guidelines.
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.
File: packages/markitdown-sample-plugin/README.md
MarkItDown Sample Plugin
This project shows how to create a sample plugin for MarkItDown. The most important parts are as follows:
First, implement your custom DocumentConverter:
from typing import BinaryIO, Any
from markitdown import MarkItDown, DocumentConverter, DocumentConverterResult, StreamInfo, PRIORITY_SPECIFIC_FILE_FORMAT
class RtfConverter(DocumentConverter):
def __init__(
self, priority: float = PRIORITY_SPECIFIC_FILE_FORMAT
):
super().__init__(priority=priority)
def accepts(
self,
file_stream: BinaryIO,
stream_info: StreamInfo,
**kwargs: Any,
) -> bool:
# Implement logic to check if the file stream is an RTF file
# ...
raise NotImplementedError()
def convert(
self,
file_stream: BinaryIO,
stream_info: StreamInfo,
**kwargs: Any,
) -> DocumentConverterResult:
# Implement logic to convert the file stream to Markdown
# ...
raise NotImplementedError()Next, make sure your package implements and exports the following:
# The version of the plugin interface that this plugin uses.
# The only supported version is 1 for now.
__plugin_interface_version__ = 1
# The main entrypoint for the plugin. This is called each time MarkItDown instances are created.
def register_converters(markitdown: MarkItDown, **kwargs):
"""
Called during construction of MarkItDown instances to register converters provided by plugins.
"""
# Simply create and attach an RtfConverter instance
markitdown.register_converter(RtfConverter())Finally, create an entrypoint in the pyproject.toml file:
[project.entry-points."markitdown.plugin"]
sample_plugin = "markitdown_sample_plugin"Here, the value of sample_plugin can be any key, but should ideally be the name of the plugin. The value is the fully qualified name of the package implementing the plugin.
Installation
To use the plugin with MarkItDown, it must be installed. To install the plugin from the current directory use:
pip install -e .Once the plugin package is installed, verify that it is available to MarkItDown by running:
markitdown --list-pluginsTo use the plugin for a conversion use the --use-plugins flag. For example, to convert an RTF file:
markitdown --use-plugins path-to-file.rtfIn Python, plugins can be enabled as follows:
from markitdown import MarkItDown
md = MarkItDown(enable_plugins=True)
result = md.convert("path-to-file.rtf")
print(result.text_content)Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
Microsoft's Trademark & Brand Guidelines.
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.
File: packages/markitdown-mcp/README.md
MarkItDown-MCP
[!IMPORTANT]
The MarkItDown-MCP package is meant for local use, with local trusted agents. In particular, when running the MCP server with Streamable HTTP or SSE, it binds tolocalhostby default, and is not exposed to other machines on the network or Internet. In this configuration, it is meant to be a direct alternative to the STDIO transport, which may be more convenient in some cases. DO NOT bind the server to other interfaces unless you understand the security implications of doing so.
The markitdown-mcp package provides a lightweight STDIO, Streamable HTTP, and SSE MCP server for calling MarkItDown.
It exposes one tool: convert_to_markdown(uri), where uri can be any http:, https:, file:, or data: URI.
Installation
To install the package, use pip:
pip install markitdown-mcpUsage
To run the MCP server, using STDIO (default), use the following command:
markitdown-mcpTo run the MCP server, using Streamable HTTP and SSE, use the following command:
markitdown-mcp --http --host 127.0.0.1 --port 3001Running in Docker
To run markitdown-mcp in Docker, build the Docker image using the provided Dockerfile:
docker build -t markitdown-mcp:latest .And run it using:
docker run -it --rm markitdown-mcp:latestThis will be sufficient for remote URIs. To access local files, you need to mount the local directory into the container. For example, if you want to access files in /home/user/data, you can run:
docker run -it --rm -v /home/user/data:/workdir markitdown-mcp:latestOnce mounted, all files under data will be accessible under /workdir in the container. For example, if you have a file example.txt in /home/user/data, it will be accessible in the container at /workdir/example.txt.
Accessing from Claude Desktop
It is recommended to use the Docker image when running the MCP server for Claude Desktop.
Follow these instructions to access Claude's claude_desktop_config.json file.
Edit it to include the following JSON entry:
{
"mcpServers": {
"markitdown": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"markitdown-mcp:latest"
]
}
}
}If you want to mount a directory, adjust it accordingly:
{
"mcpServers": {
"markitdown": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-v",
"/home/user/data:/workdir",
"markitdown-mcp:latest"
]
}
}
}Debugging
To debug the MCP server you can use the MCP Inspector tool.
npx @modelcontextprotocol/inspectorYou can then connect to the inspector through the specified host and port (e.g., http://localhost:5173/).
If using STDIO:
- select
STDIOas the transport type, - input
markitdown-mcpas the command, and - click
Connect
If using Streamable HTTP:
- select
Streamable HTTPas the transport type, - input
http://127.0.0.1:3001/mcpas the URL, and - click
Connect
If using SSE:
- select
SSEas the transport type, - input
http://127.0.0.1:3001/sseas the URL, and - click
Connect
Finally:
- click the
Toolstab, - click
List Tools, - click
convert_to_markdown, and - run the tool on any valid URI.
Security Considerations
The server does not support authentication, and runs with the privileges of the user running it. For this reason, when running in SSE or Streamable HTTP mode, the server binds by default to localhost. Even still, it is important to recognize that the server can be accessed by any process or users on the same local machine, and that the convert_to_markdown tool can be used to read any file that the server's user has access to, or any data from the network. If you require additional security, consider running the server in a sandboxed environment, such as a virtual machine or container, and ensure that the user permissions are properly configured to limit access to sensitive files and network segments. Above all, DO NOT bind the server to other interfaces (non-localhost) unless you understand the security implications of doing so.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
Microsoft's Trademark & Brand Guidelines.
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.
File: packages/markitdown/README.md
MarkItDown
[!TIP]
MarkItDown is a Python package and command-line utility for converting various files to Markdown (e.g., for indexing, text analysis, etc).For more information, and full documentation, see the project README.md on GitHub.
[!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 narrowestconvert_*function needed for your use case (e.g.,convert_stream(), orconvert_local()). See the Security Considerations section of the documentation for more information.
Installation
From PyPI:
pip install 'markitdown[all]'From source:
git clone [email protected]:microsoft/markitdown.git
cd markitdown
pip install -e 'packages/markitdown[all]'Usage
Command-Line
markitdown path-to-file.pdf > document.mdPython API
from markitdown import MarkItDown
md = MarkItDown()
result = md.convert("test.xlsx")
print(result.text_content)More Information
For more information, and full documentation, see the project README.md on GitHub.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
Microsoft's Trademark & Brand Guidelines.
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.
2. Official Technical Reference & Guides (microsoft/microsoft.github.io)
[microsoft.github.io](https://microsoft.github.io)
Many open source projects released by Microsoft products, services and teams also have
deployments powered by GitHub Pages on this domain.
To discover Microsoft-released open source projects, learn about Microsoft's open source
approach and other information, check us out online at opensource.microsoft.com.
If we can help answer questions about the open source program at Microsoft, you can
contact opensource at microsoft com - although we are not able to provide support
for projects through this mechanism.
Microsoft GitHub resources
- Default repo templates including
SECURITY.MDand code of conduct files: microsoft/repo-templates - Code of Conduct (FAQ)
Microsoft open source resources
Resources for Microsoft employees
How to identify an official Microsoft organization on GitHub
- Official Microsoft GitHub orgs have a professional avatar and include a web address at Microsoft.com or an associated official domain
- Official Microsoft orgs are Verified on GitHub - look for the domain verification indicator on GitHub