DEV Community

Jeremy Xiao
Jeremy Xiao

Posted on

Microsoft MarkItDown: install it, use the CLI, and know when a browser converter is simpler

Disclosure: I work on markitdown.tech, which wraps Microsoft's MarkItDown. The site is not open source itself and is not affiliated with Microsoft.

Microsoft's MarkItDown is a lightweight Python utility that turns PDFs, Office files, images, audio, HTML and more into Markdown for LLMs and text pipelines. It aims to keep structure (headings, lists, tables, links) rather than reproduce page layout. This post walks through the install and CLI commands as they appear on the Microsoft MarkItDown page at markitdown.tech, and shows when a browser converter is the simpler path for a one-off file.

The top of the Microsoft MarkItDown page: the heading, a short intro and the Try It Online and See Install Commands buttons

Install it (Python 3.10 or newer)

MarkItDown needs Python 3.10 or newer, and the README recommends a virtual environment. Installing with the [all] extra pulls in every format dependency:

pip install 'markitdown[all]'
Enter fullscreen mode Exit fullscreen mode

If you want a smaller dependency list, install only the extras you need:

pip install 'markitdown[pdf, docx, pptx]'
Enter fullscreen mode Exit fullscreen mode

The page's FAQ also says you can clone the repository from GitHub and install from source, and that the library is published as an official Docker build target. Check the official repository for those steps.

Use the CLI and the Python API

The command-line tool writes Markdown to standard output or to a file with -o, and it reads from a pipe too:

markitdown path-to-file.pdf > document.md
markitdown path-to-file.pdf -o document.md
cat path-to-file.pdf | markitdown
Enter fullscreen mode Exit fullscreen mode

From Python you create a MarkItDown instance, call convert(), and read result.markdown:

from markitdown import MarkItDown

md = MarkItDown()
result = md.convert("test.xlsx")
print(result.markdown)
Enter fullscreen mode Exit fullscreen mode

The Install and Run Microsoft MarkItDown section with the numbered install steps and a terminal block

Library or browser?

The library is the right choice for pipelines: scripts, batch jobs, notebooks and CI runs. A browser converter is simpler when you have a single contract, deck or spreadsheet and do not want to set up Python. The built-in converters work best on files that have a text layer; for scans and photos of pages the markitdown.tech site adds AI OCR (the page's FAQ says free accounts include 10 OCR pages per month and Pro raises that to 500).

The Run Microsoft MarkItDown in Your Browser area with Server conversion and Local conversion options

A real one-off conversion

To see it work, I made a tiny HTML file on my own machine: a heading, one paragraph, a two-item list and a two-row table. I chose Local conversion on the page and selected the file. The page showed sample-notes.md, 23 words and 168 characters, and the Markdown tab showed the heading as # Weekly Notes, the list items as bullets and the table as pipe-delimited rows.

The Markdown output for the sample file, showing the heading, bullet list and table rows

That is one small file, not a benchmark, so treat it as a sanity check only. For anything important, compare the output with your source document.

Where to go next

If you just need the commands or want to try a file in your browser, the Microsoft MarkItDown page has both in one place.

Top comments (0)