MarkItDown: Stop PDFs Eating Your Claude Tokens
Microsoft's free MarkItDown converts a document into clean markdown before Claude sees it, so the page images never cost you tokens. Includes the Claude Desktop MCP setup.
When you hand Claude a PDF, every page is converted into an image and the text from that page is extracted and sent alongside the image. Anthropic's own PDF support documentation puts the text at roughly 1,500 to 3,000 tokens per page depending on how dense the content is, and the image of each page is charged on top of that using the normal image cost calculation. On that documented estimate, the text of a 20 page report alone works out at somewhere around 30,000 to 60,000 tokens before you ask your first question, with the page images still to be added. That is an estimate from the published per-page figure rather than a number Anthropic publishes for a 20 page file.
MarkItDown is a free, open source Python utility from Microsoft that converts a document into clean markdown before any model sees it. Headings, lists, tables and links survive the conversion, so Claude reads structured text and the page images never enter the conversation at all. The repository has over 186,000 stars on GitHub at the time of writing.
microsoft/markitdown on GitHub
What it converts
- PDF, Word, PowerPoint and Excel documents.
- Images, using EXIF metadata and OCR.
- Audio, using EXIF metadata and speech transcription.
- HTML, and text based formats such as CSV, JSON and XML.
- ZIP archives, which it iterates over, plus EPubs and YouTube URLs.
Install it
MarkItDown needs Python 3.10 through 3.14. Microsoft recommends a virtual environment so the optional format dependencies do not collide with anything else you have installed.
python -m venv .venv
source .venv/bin/activate
pip install 'markitdown[all]'The [all] extra pulls in every format. If you only ever touch a couple of file types you can install those alone, which keeps the install much smaller.
pip install 'markitdown[pdf, docx, pptx]'Convert a file from the command line
Point it at a file and it prints markdown to standard output, so you can redirect that into a .md file.
markitdown path-to-file.pdf > document.mdThe -o flag does the same thing without the shell redirect, and you can pipe a file in on standard input instead.
markitdown path-to-file.pdf -o document.md
cat path-to-file.pdf | markitdownNow upload document.md to Claude in place of the original PDF. You are paying for the words and the structure, and nothing else.
Wire the MCP server into Claude Desktop
The same repository ships a small MCP server called markitdown-mcp. It exposes one tool, convert_to_markdown(uri), which accepts an http:, https:, file: or data: URI. With it connected, Claude Desktop can convert a document itself rather than you running the CLI first.
- Install the server package: pip install markitdown-mcp
- Open Claude Desktop, go to Settings, then Developer, then Edit Config. That opens claude_desktop_config.json.
- Add the entry below, save the file and fully quit and reopen Claude Desktop.
{
"mcpServers": {
"markitdown": {
"command": "markitdown-mcp",
"args": []
}
}
}Microsoft recommends the Docker image for Claude Desktop, which keeps the server and its dependencies isolated from your machine. Build the image from the repository with docker build -t markitdown-mcp:latest . and use this entry instead. To let it reach local files, mount the folder they live in and refer to them under /workdir.
{
"mcpServers": {
"markitdown": {
"command": "docker",
"args": ["run", "--rm", "-i", "-v", "/Users/you/Documents:/workdir", "markitdown-mcp:latest"]
}
}
}- Ask Claude to convert a file to markdown and check that the markitdown tool is the one it calls.
Use the markitdown tool to convert file:///workdir/contract.pdf to markdown, then summarise the payment terms, the termination clause and anything unusual about the liability section. Quote the exact wording from the markdown for every point you raise.Worth knowing
- markitdown-mcp is built for local use with trusted agents. Over HTTP or SSE it binds to localhost by default, and Microsoft's own warning is not to bind it to other interfaces unless you understand what that exposes.
- MarkItDown reads files with the privileges of whatever process runs it, so treat untrusted documents with the same care you would give any file you open.
- The output is built for models to read rather than for people to look at, so a heavily designed brochure will come back plainer than the original.
- A scanned PDF holds pictures of words rather than text. Converting one gives you very little, and that is the case where sending Claude the original pages still earns its tokens.
New guides land in your inbox first
One short email a week with the tools and prompts worth your time. Free, and you can leave any time.