Skip to content
Search

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
  • Has experience building a feature at work that converts files into LLM-friendly text
    • 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
  • Many startups and open-source projects overcomplicate this space, but a simple project that is easy to understand and easy to deploy is the ultimate goal
  • Would like a way to control "how much processing you want" for PDFs
    • 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
  • For PDF processing, it may be better to integrate PDFMiner directly
  • Pandoc can convert .docx files to Markdown and other file formats
    • Pandoc cannot convert PowerPoint or Excel files
  • Indexed tabletop RPG books in PDF format with complex visual layouts and many tables
    • 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
  • Unexpected but positive that the README does not mention LLMs
    • The code is interesting to read
    • Most of it is glue code in a single 1101-line file
  • Shared an experience of submitting assignments via Slack in an online language class
    • 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
  • Curious about a comparison with docling
    • docling uses LLMs
  • Wondering whether there is a good library for converting Markdown to PDF or .docx
    • Pandoc can do it in most cases but struggles with certain elements such as tables
  • If it is Microsoft, it should be able to produce half-decent results from Outlook HTML and .docx
    • Evaluated most of the paid solutions too, but none seemed good enough to run in production
    • Will try this tool

See also

Favorite site

author Zer0 sitemap