PDF to Markdown for LlamaIndex — Structured Ingestion
LlamaIndex's SimpleDirectoryReader will happily ingest a PDF, but its default node-parsing on PDF text is generic — sentence splitting on whatever the PDF parser hands back. Pre-convert to Markdown and you can use MarkdownNodeParser, which builds a node tree that mirrors the document's real heading hierarchy.
Why MarkdownNodeParser changes the math
The default LlamaIndex flow on PDFs flattens everything to text and then sentence-splits. That's fine for short documents but disastrous for anything structured: a 60-page report becomes a long list of sentences with no hint that section 4.2 is part of chapter 4. Retrieval then surfaces orphan sentences instead of coherent passages.
MarkdownNodeParser builds a hierarchical node graph: H1 nodes contain H2 nodes contain H3 nodes contain paragraph nodes. Retrieval can climb the hierarchy, your prompts can include parent context, and your re-ranker has structural signal to work with.
Code example
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
from llama_index.core.node_parser import MarkdownNodeParser
# 1. Load pre-converted Markdown files
documents = SimpleDirectoryReader(
input_dir="./markdown_docs",
required_exts=[".md"],
).load_data()
# 2. Parse into hierarchical nodes via the Markdown structure
parser = MarkdownNodeParser()
nodes = parser.get_nodes_from_documents(documents)
# 3. Index — each node now carries its heading path as metadata
index = VectorStoreIndex(nodes)
query_engine = index.as_query_engine(similarity_top_k=5)
Frequently asked questions
MarkdownNodeParser vs SentenceSplitter for PDF content?
MarkdownNodeParser respects document hierarchy and gives nodes structural metadata. SentenceSplitter just chops on sentence boundaries — fine for prose, terrible for technical documents where section context matters. For converted PDF content, always prefer MarkdownNodeParser.
How do I set up a LlamaIndex ingestion pipeline with Markdown?
Standard pattern: load .md files with SimpleDirectoryReader (required_exts=[".md"]), parse with MarkdownNodeParser, build a VectorStoreIndex over the nodes. The whole pipeline is ~10 lines and produces noticeably better retrieval than the equivalent on raw PDF.
Does Markdown preserve metadata for LlamaIndex nodes?
Yes — MarkdownNodeParser automatically promotes the heading path to node metadata, so each node knows it lives under "Chapter 4 > Section 4.2 > Methodology". Your queries and re-rankers can use that metadata directly.
Can I build hierarchical nodes from Markdown headings?
That's exactly what MarkdownNodeParser does. The resulting nodes form a tree that mirrors your document's table of contents, which means you can do parent-child retrieval, summary-based routing, or auto-merging-retriever patterns out of the box.
SimpleDirectoryReader vs pre-converted Markdown: which is better?
For one-off ingestion, SimpleDirectoryReader on PDFs is simpler. For anything you'll re-index more than once, pre-convert to Markdown — your indexing time drops, your chunks become deterministic, and your output is human-inspectable for debugging.
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.