Word to Markdown for LangChain — Better Than Docx2txt
Docx2txtLoader is the standard LangChain loader for Word documents — and it flattens every heading into plain text. Section structure disappears, downstream chunking has nothing to anchor on, and your retrieval surfaces context-less fragments. Pre-convert to Markdown and TextLoader plus MarkdownHeaderTextSplitter handles structure cleanly: each section becomes its own document with the heading path already in metadata.
The cleaner LangChain pipeline
The standard advice is Docx2txtLoader, which extracts text and discards structure. Fine for simple summarisation; painful for any pipeline that needs heading-aware chunking. The alternative: pre-convert each Word document on Word to Markdown, persist the .md, and use TextLoader from then on. Your loader becomes deterministic, your output is human-inspectable, and your splitter can rely on real section boundaries.
Pair with MarkdownHeaderTextSplitter
The single biggest win is the splitter. MarkdownHeaderTextSplitter chunks on actual heading boundaries instead of guessing — chunks correspond to document sections, the heading path lives in metadata, and retrieval-augmented prompts get free structural context. Combine with PDFs (PDF for LangChain), URLs (URL for LangChain), audio (Audio for LangChain), and video (Video for LangChain) for a multi-source pipeline.
Code example
# Local pipeline using LangChain on the .md you downloaded from mdisbetter.com.
# Install: pip install langchain-community langchain-text-splitters
from langchain_community.document_loaders import TextLoader
from langchain_text_splitters import MarkdownHeaderTextSplitter, RecursiveCharacterTextSplitter
# 1. Load the converted Word document
docs = TextLoader("vendor-contract-template.md", encoding="utf-8").load()
md_text = docs[0].page_content
# 2. Split on section headings — each ## becomes a chunk with section metadata
md_splitter = MarkdownHeaderTextSplitter(headers_to_split_on=[
("#", "document"),
("##", "section"), # ## 4. Termination
("###", "subsection"),
])
section_chunks = md_splitter.split_text(md_text)
# 3. Sub-split any over-budget section for your embedding model
splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=120)
chunks = splitter.split_documents(section_chunks)
# Each chunk's metadata['section'] is e.g. "4. Termination"
Frequently asked questions
MarkdownHeaderTextSplitter vs Docx2txtLoader for Word documents?
Docx2txtLoader returns flat text — heading structure flattened, chunking has to guess at boundaries. Pre-converting to Markdown and using MarkdownHeaderTextSplitter gives you section-aware chunks with heading metadata. Use the converter for the structure, then any standard LangChain text-handling primitive works downstream.
Can I attach section metadata to every chunk automatically?
Yes — automatic with MarkdownHeaderTextSplitter. The heading text (e.g. 4. Termination or 3.2 Force Majeure) becomes a metadata field on each chunk. Retrieval can filter by section; synthesis can cite by section heading.
How is this different from UnstructuredWordDocumentLoader?
UnstructuredWordDocumentLoader uses the unstructured library to extract richer metadata — it's a step up from Docx2txtLoader. The pre-conversion approach is even cleaner: you get Markdown you can inspect and hand-correct before ingestion, and the same TextLoader code works across all your converted source modalities (PDF, URL, audio, video, Word).
What about Word documents with embedded tables and lists?
The converter renders Word tables as Markdown tables (pipe syntax) and Word lists as Markdown lists. MarkdownHeaderTextSplitter respects table and list boundaries — chunks won't slice through a table mid-row. For documents heavy in structured data (compliance matrices, comparison tables), this is significantly cleaner than Docx2txtLoader's output.
Should I run conversion on a server or use the web tool?
For ad-hoc and progressive ingestion (a few documents at a time), the web tool at mdisbetter.com is the right surface — upload, download, drop into your pipeline. For automated batch ingestion of thousands of documents, run Pandoc locally in a script (pandoc input.docx -o output.md). Same Markdown output, different operational surfaces.
Your AI doesn't read PDFs directly. It first has to extract the text, decode the layout, ignore the metadata — before it can even start answering. A Markdown file removes all of those steps. Your AI reads it instantly. So you get faster responses, more accurate results, and zero information lost along the way.
Size-wise, it's 100 to 500 times lighter for the same content. A 15 MB PDF becomes a 30 KB .md file. So your AI knowledge base can hold hundreds of documents instead of a handful.
MDisBetter brings 19 free tools together for that — documents, videos, audio, web pages and prompts.
How does it work?
Drop a PDF, a video, an audio file or a URL. MDisBetter extracts the content and gives you a clean Markdown file. So you can send it to your AI, add it to your project files, or store it in your knowledge base — without losing anything.
Frequently Asked Questions
How do I convert a PDF to Markdown for free?
Upload your PDF to MDisBetter, click Convert, and get structured Markdown in seconds. No signup, no installation — it works directly in your browser. The free plan includes 50 credits per month.
Why is Markdown better than PDF for AI?
Markdown reduces token usage by up to 95% compared to PDF. AI models like ChatGPT and Claude process Markdown far more efficiently because it contains only content structure — no fonts, no layout data, no binary overhead.
What file types can MDisBetter convert?
MDisBetter converts PDF, Word (.docx), plain text, YouTube videos (transcript), audio files (MP3, WAV, M4A, OGG, FLAC, WEBM), and any web page URL to clean Markdown.
Is MDisBetter free?
Yes, free to start. The free plan includes 50 credits per month. All processing happens securely — your files are never stored.
Can I extract a YouTube transcript as Markdown?
Yes. Paste the YouTube video URL, click Convert, and get the full transcript structured as Markdown with headings and timestamps. Perfect for feeding video content to AI tools.
PDF → Markdown
Faithful and structured conversion of your documents
Text to MD, EPUB to MD, MD to PDF, MD Cleaner, Merger, Chunker, Token Counter, Context Builder
Free
—
Word to MD
0.5 credit
per page
Excel to MD
0.5 credit
per conversion
Single URL Scrape
0.5 credit
per call
Site Crawl
1 credit
per page
Translate
1 credit
per 10 000 chars (min 1, free re-translation on cache hit)
Prompt Optimizer
1 credit
per call
System Prompt Generator
1 credit
per call
Audio to MD
2 credits
per minute
Video to MD
2 credits
per minute
YouTube to MD
2 credits
per minute
Image OCR
4 credits
per image (0 on cache hit)
PDF to MD
4 credits
per page
PPTX to MD
4 credits
per slide
Questions
Yes! You get 50 credits every month to use any tool. Basic tools like MD Cleaner or Token Counter cost just 0.5 credit per use. When you run out, credits reset the next month or you can upgrade for more.
Wait for your monthly reset or upgrade to a higher plan. Credits renew on your billing date each month.
Yes, cancel anytime with one click. No questions asked. You keep access until the end of your billing period.
Pro gives you 30,000 credits for $29 — that's 30x more credits than Starter for just 3x the price. Every credit costs less, so you get far more value per dollar.