When you want an LLM to read an internal document, you cannot pass it a Word or Excel file as-is. Copying and pasting by hand can break the heading hierarchy and table structure. markitdown is a Microsoft tool that converts Office documents, PDFs, and other file formats into Markdown that LLMs can read. I installed it and tested whether conversion worked with the network disabled.
markitdown converts a wide range of file formats, including Word, Excel, PowerPoint, PDF, and HTML, into Markdown while preserving their structure. Microsoft publishes the source under the MIT License (*1).
1. Install it
Install markitdown with the [all] extra so that all supported formats are available. I install python-docx to create the test Word document; markitdown does not depend on it.
FROM docker.io/library/python:3.12.13-slim
RUN pip install --no-cache-dir --quiet 'markitdown[all]==0.1.6' 'python-docx==1.2.0'
WORKDIR /work
podman build -t markitdown-sandbox .
2. Convert a Word document to Markdown
I created a dummy Word document with headings, paragraphs, and a table, then passed it to markitdown without modification. I ran the conversion with the network disabled.
# make_docx.py
from docx import Document
doc = Document()
doc.add_heading("Quarterly Report", level=1)
doc.add_paragraph("This report summarizes rootless container adoption across three teams.")
doc.add_heading("Findings", level=2)
doc.add_paragraph("Teams that switched to rootless Podman reported fewer permission issues.")
table = doc.add_table(rows=3, cols=2)
table.rows[0].cells[0].text = "Team"
table.rows[0].cells[1].text = "Adoption"
table.rows[1].cells[0].text = "Platform"
table.rows[1].cells[1].text = "100%"
table.rows[2].cells[0].text = "Infra"
table.rows[2].cells[1].text = "60%"
doc.save("/work/report.docx")
# convert_demo.py
from markitdown import MarkItDown
md = MarkItDown()
result = md.convert("/work/report.docx")
print(result.text_content)
podman run --rm --network none --memory 2g --cpus 2 --pids-limit 512 \
-v "$(pwd)":/work -w /work markitdown-sandbox \
bash -c "python make_docx.py && python convert_demo.py"
-v makes the specified directory readable and writable from the container. Run this in an empty directory set aside for the experiment, and do not place unpublished documents or other secrets there.
The output was:
# Quarterly Report
This report summarizes rootless container adoption across three teams.
## Findings
Teams that switched to rootless Podman reported fewer permission issues.
| | |
| --- | --- |
| Team | Adoption |
| Platform | 100% |
| Infra | 60% |
The heading hierarchy (# and ##) and paragraphs stayed intact. markitdown converted the table to Markdown table syntax, but it did not treat the first row, which should contain the Team and Adoption headings, as a header. It generated an empty header row above it. Before you use this tool, inspect the converted table with real data to confirm that its header row matches your intent.
Keep document structure intact when you copy and paste
Copying and pasting a document with headings and tables into an LLM does not preserve its structure. With a conversion tool such as markitdown, you can pass the document to an LLM and keep its heading hierarchy and table delimiters in Markdown. Conversion details can vary by format, so inspect the output before you pass it on.
Sources
*1 markitdown (GitHub), https://github.com/microsoft/markitdown, MIT License