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.
At present, MarkItDown supports:
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.
The primary way to use MarkItDown is via Docker.
docker run --rm -i jerryin/markitdown:latest < ~/your-file.pdf > output.md
The included .bash_profile provides a convenient markitdown() shell function that simplifies the process.
1. Setup
To use it, source the file in your current shell session:
source .bash_profile
For persistent use, add this command to your shell's startup file (e.g., ~/.bashrc or ~/.zshrc).
2. Examples
Convert a local file: This command will convert your-file.pdf and automatically save the output to your-file.md.
markitdown your-file.pdf
Piping from stdin or passing arguments: The function also handles other cases, like piping content or passing command-line arguments to the container.
cat your-file.txt | markitdown > output.md
markitdown --help
Content type
Image
Digest
sha256:5361e5889…
Size
378.5 MB
Last updated
about 2 months ago
docker pull jerryin/markitdown