MarkItDown: Python utility for converting files to Markdown

MarkItDown is a Python utility for converting various files to Markdown for use with LLMs and related text analysis pipelines.

Verified

On this page

What it is

MarkItDown is a Python utility for converting various files to Markdown for use with LLMs and related text analysis pipelines. The README says it is most comparable to textract, with a focus on preserving important document structure and content as Markdown, including headings, lists, tables, links, etc. Its output is meant for text analysis tools and may not suit high-fidelity document conversions for human consumption. The repository is intended to provide Python libraries that can be incorporated into other systems.

Core facts

Read by a script from the official API, not rewritten by a model.

License
MIT
Languages
Python
Maintainer
microsoft
Verified

Main features

  1. It currently supports conversion from text-based formats (CSV, JSON, XML).

  2. ZIP files are also supported, and the converter iterates over their contents.

  3. Images are supported too, with EXIF metadata and captioning.

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

  5. The markitdown-ocr plugin adds OCR support to PDF, DOCX, PPTX, and XLSX converters, extracting text from embedded images using LLM Vision.

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

  7. Image descriptions with Large Language Models currently work only for pptx and image files, and require llm_client and llm_model.

  8. max_retries controls the OpenAI client's automatic retries for retryable errors; the default is 2, and 5 allows up to six attempts with backoff.

  9. If the client raises an error after exhausting its retries, or encounters a non-retryable error, MarkItDown tries other applicable converters and raises FileConversionException only if none succeeds.

  10. In the README's Document Intelligence section, if AZURE_API_KEY is not set, MarkItDown uses DefaultAzureCredential.

  11. In that section, no analysis add-ons are enabled by default.

  12. For Content Understanding, each convert method call for a CU-routed format is a billable Azure API call.

  13. cu_file_types restricts which formats route to CU.

  14. When cu_analyzer_id is set, the converter automatically scopes it to compatible file types based on the analyzer's modality.

Getting started

  1. MarkItDown requires Python 3.10 through 3.14.

  2. The README recommends a virtual environment to avoid dependency conflicts.

  3. To install MarkItDown, use pip.

  4. Earlier in the README all optional dependencies were installed, but they can also be installed individually for more control.

  5. The example that installs the pdf, docx and pptx options will install only the dependencies for PDF, DOCX, and PPTX files.

  6. The pdf option installs dependencies for PDF files.

  7. The audio-transcription option installs dependencies for audio transcription of wav and mp3 files.

  8. The command line accepts an option to specify the output file.

  9. Content can also be piped in.

  10. 3rd-party plugins are disabled by default.

  11. The README gives a command for listing installed plugins.

  12. It also gives a command for enabling plugins.

  13. To find available plugins, search GitHub for the hashtag #markitdown-plugin.

From the README
Shell
python -m venv .venv
source .venv/bin/activate
From the README
Shell
git clone git@github.com:microsoft/markitdown.git
cd markitdown
pip install -e 'packages/markitdown[all]'
From the README
Shell
markitdown path-to-file.pdf > document.md
From the README
Shell
markitdown path-to-file.pdf -o document.md
From the README
Shell
pip install 'markitdown[pdf, docx, pptx]'
From the README
python
from markitdown import MarkItDown

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

Who it is for

MarkItDown performs I/O with the privileges of the current process, and like open or requests.get, it will access resources that the process itself can access. Do not pass untrusted input directly to MarkItDown. The README says to prefer the narrowest conversion API that fits the use case.

The convert method is intentionally permissive and can handle local files, remote URIs, and byte streams. An application that only needs to read local files can call convert_local instead. For 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 to be converted and call convert_stream. Image captioning, speech transcription, Azure Document Intelligence, and Azure Content Understanding rely on web-hosted services to function. For local-only operations, install only the optional dependencies that are needed and wanted.

Sources

This page is written from the official sources below. Open them to check the original text.

Verified ·

This page is written by AI from the official sources above and checked automatically. This site has not tested it. Found a mistake? Tell us.