URL to Markdown for LlamaIndex — Clean Web Ingestion
LlamaIndex's SimpleWebPageReader is convenient and shallow — it fetches a URL, strips some tags, returns text. The text then flatlines through SentenceSplitter, losing every shred of section structure the page had. Pre-convert to Markdown and you can use MarkdownNodeParser, which builds nodes that mirror the page's real heading hierarchy.
What SimpleWebPageReader misses
SimpleWebPageReader extracts a flat blob of text and hands it to whatever node parser you configure. Default node parsing is sentence-level, which on web articles produces nodes with no hint that "Section 3" is part of "Chapter 2" — every retrieved sentence is an orphan. Synthesis then has to re-derive context that was thrown away at ingestion.
Pre-converting to Markdown and using MarkdownNodeParser changes the math. Nodes form a tree: H1 → H2 → H3 → paragraph. Retrieval can climb the tree, your prompts can include parent context, your re-ranker has structural signal to work with.
Code example
# Self-rolled URL-to-Markdown ingestion for LlamaIndex.
# Install: pip install trafilatura llama-index
import trafilatura
from llama_index.core import Document, VectorStoreIndex
from llama_index.core.node_parser import MarkdownNodeParser
# 1. Fetch + extract Markdown (replaces SimpleWebPageReader)
def fetch_as_markdown(url: str) -> Document | None:
downloaded = trafilatura.fetch_url(url)
md = trafilatura.extract(
downloaded,
output_format="markdown",
include_links=True,
include_tables=True,
)
if not md:
return None
return Document(text=md, metadata={"source_url": url})
documents = [d for d in (fetch_as_markdown(u) for u in [
"https://example.com/docs/intro",
"https://example.com/docs/advanced",
]) if d is not None]
# 2. Parse into hierarchical nodes via Markdown structure
parser = MarkdownNodeParser()
nodes = parser.get_nodes_from_documents(documents)
# 3. Index — each node carries its heading path AND source URL
index = VectorStoreIndex(nodes)
query_engine = index.as_query_engine(similarity_top_k=5)
# For one-off URLs you don't want to script, paste into
# mdisbetter.com/convert/url-to-markdown and load the .md with SimpleDirectoryReader.
Frequently asked questions
SimpleWebPageReader vs pre-converted Markdown for LlamaIndex?
SimpleWebPageReader is fine for prototypes and clean static sites. For production, JS-heavy pages, or any corpus with consistent structural needs, pre-conversion gives you deterministic ingestion plus hierarchical MarkdownNodeParser nodes — strictly better for retrieval quality.
How does MarkdownNodeParser handle web content?
Identically to any other Markdown source — it builds a node tree mirroring the heading hierarchy. Web content, once converted, looks no different to MarkdownNodeParser than a hand-written README. The hierarchy enables auto-merging-retriever and parent-context patterns out of the box.
Can I attach source URLs as node metadata?
Yes — pass metadata={"source_url": url} when constructing the Document, and it propagates to every node parsed from that document. Your synthesis prompt can then cite the originating URL for each retrieved chunk.
What about web pages with code blocks (Stack Overflow, docs)?
Code blocks in the source HTML are converted to fenced Markdown code blocks (with language hints when the source uses them). MarkdownNodeParser preserves them as discrete nodes, which means retrieval can surface code snippets as units rather than splitting them mid-function.
How do I re-ingest when web pages change?
Re-convert the URLs, delete the affected nodes from your index by source_url metadata, and re-insert. LlamaIndex's vector stores all support metadata-filtered deletion — Pinecone, Chroma, Weaviate, and Qdrant included.
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.