MarkItDown
lastmod 2024-12-17created 2024-12-171 edits
A Python tool from Microsoft for converting files and office documents to Markdown
A utility tool that converts a variety of files to Markdown.
Supported formats
- PDF (.pdf), PowerPoint (.pptx), Word (.docx), Excel (.xlsx)
- Images (EXIF metadata and OCR), audio (EXIF metadata and speech transcription)
- HTML (with special handling for Wikipedia, etc.) and various other text-based formats (csv, json, xml, etc.)
Usage
The API is simple to use:
from markitdown import MarkItDown
markitdown = MarkItDown()
result = markitdown.convert("test.xlsx")
print(result.text_content)
Hacker News comments
- MarkItDown: Python tool for converting files and office documents to Markdown | Hacker News
- If you have uv installed, you can run it on a file without a separate install using the command uvx markitdown path-to-file.pdf
- The first run caches the required packages, and later runs reuse the cached packages
- Tried it on HTML and PDF and it performed quite well
- After reading the source code, this implementation seems quite reasonable
- Better not to use it for images or spreadsheets
- Images can be passed directly to the LLM provider, and for spreadsheets, Markdown table interpretation is weak
- Extracting text from PDFs requires either heuristics that are sensitive to how the PDF was exported, or full OCR
- It is inconvenient for a project to be locked into just one method
- Will not use the speech-to-text feature, since it may have different performance characteristics from the text-to-text features
- Pandoc cannot convert PowerPoint or Excel files
- If it is a wrapper around PDFMiner, there is no visible added value in this tool
- It does not recognize or process tables, but there is minimal table cell recognition
- Handles variable-width columns and text wrapped in complex ways well
- Inserts unnecessary spaces into fully justified text and adds unnecessary line breaks when columns split mid-sentence
- The biggest problem is that it misses headings entirely
- The code is interesting to read
- Most of it is glue code in a single 1101-line file
- Submitted an assignment as a .md file, but the teacher did not understand it
- Never expected to meet someone who preferred Word documents after that
- docling uses LLMs
- Pandoc can do it in most cases but struggles with certain elements such as tables
- Evaluated most of the paid solutions too, but none seemed good enough to run in production
- Will try this tool