Markdown for LLMs: How to Prepare Documents for ChatGPT, Claude and RAG
By the MDConverter team · Updated · 5 min read
Quick answer
Convert documents to Markdown before giving them to an AI model. Markdown keeps the structure that matters — headings, lists, tables, links — while dropping the layout code that wastes tokens, so ChatGPT, Claude or a RAG pipeline reads the content accurately and more of it fits in the context window. Use a converter for each source type (PDF, Word, PowerPoint, web pages), check the output, then split long documents at their headings.
Why Markdown is the best input format for AI models
1. Structure survives. A heading is ##, a list item is -, a table is rows of pipes. The model sees which text is a title, which is a step and which numbers belong to which column — information that is often lost when a PDF is flattened to raw text.
2. Fewer tokens. Models read and bill by token (roughly four characters of English text per token). HTML spends most of its characters on tags and attributes; Markdown spends almost none. We ran a typical pricing block — a heading, a sentence, a three-row table and two links — through our HTML to Markdown converter: 575 characters of HTML became 227 characters of Markdown, about 60% smaller, with nothing meaningful lost.
3. You can see exactly what the model sees. A PDF can look perfect on screen while its text layer is out of order. Converting first lets you spot scrambled columns, missing tables or repeated page headers before they confuse the answer.
4. Models are fluent in it. Much of the well-structured text models learn from — documentation, READMEs, Q&A sites — is Markdown, which is also why they answer in it.
## Pricing
All plans include **unlimited** projects.
| Plan | Price | Seats |
| --- | --- | --- |
| Starter | $9 | 1 |
| Team | $29 | 10 |
| Business | $99 | 50 |
- [Read the docs](https://example.com/docs)
- Cancel any timePricing
All plans include unlimited projects.
| Plan | Price | Seats |
|---|---|---|
| Starter | $9 | 1 |
| Team | $29 | 10 |
| Business | $99 | 50 |
- Read the docs
- Cancel any time
<div> with classes, a <thead> table and a styled list.How to convert each type of document
| Source | Tool | What to check afterwards |
|---|---|---|
| PDF (digital, with selectable text) | PDF to Markdown | Reading order in multi-column pages; tables; repeated headers and footers |
| Scanned PDF or photo | OCR first — see TesseractOCR.org — or a layout-aware tool such as Docling | Spelling errors from OCR; tables |
| Word (.docx) | Word to Markdown | Heading levels; images (kept as alt text) |
| Google Docs | Google Docs to Markdown | Comments and suggestions are not included |
| PowerPoint (.pptx) | PowerPoint to Markdown | One heading per slide; speaker notes |
| Excel (.xlsx) | Excel workbook to Markdown | One table per sheet; very wide sheets |
| Web page | URL to Markdown or HTML to Markdown | Navigation and cookie banners removed |
| E-book (.epub) | EPUB to Markdown | Chapter headings |
| Jupyter notebook | Notebook to Markdown | Whether to keep cell outputs |
| Plain text or an email | Text to Markdown | Headings and lists it guessed; wrapped lines |
| Rich Text (.rtf) | RTF to Markdown | Fonts and colours are dropped |
| OpenAPI / Swagger spec | Swagger to Markdown | Whether to keep every schema |
| CSV / JSON | CSV to Markdown, JSON to Markdown | Large datasets are better as files than prompt text |
Every converter on MDConverter runs in your browser, so a confidential document is not uploaded anywhere while you prepare it — you decide what is sent to the AI.
Clean-up checklist before you paste or upload
- Remove page furniture. Repeated headers, footers, page numbers and "Confidential — do not distribute" lines add noise to every chunk.
- Fix heading levels. One
#title, then##sections and###sub-sections. Models and chunkers use these as boundaries. - Keep tables as tables. If a table came out as loose lines of numbers, rebuild it — a model cannot reliably tell which value belongs to which column otherwise.
- Describe images that matter. Converters keep image alt text, not the picture. Add a sentence for any chart or diagram the answer depends on.
- Delete boilerplate. Legal disclaimers, tables of contents and cover pages rarely help and cost tokens.
- Check special characters. Ligatures (fi), hyphenation at line ends and smart quotes from PDFs can break search and matching.
Splitting Markdown for RAG (retrieval-augmented generation)
For a knowledge base or a retrieval pipeline, Markdown headings give you natural chunk boundaries:
- Split at
##or###headings first, then only split further if a section is still too long. A few hundred to about a thousand tokens per chunk is a common starting point; tune it against real questions. - Prefix each chunk with its heading path (for example
Employee handbook > Leave > Parental leave) so a chunk still makes sense when it is retrieved on its own. - Never split inside a table or a code block. Keep them whole, even if that chunk runs long.
- Keep links. A cited URL in the chunk lets the model point readers to the source.
If you need batch processing, OCR and layout analysis across thousands of files, an open-source pipeline such as Docling is the better fit; browser converters are best for individual documents you want to check by eye.
Using Markdown inside your prompts
Markdown also makes prompts clearer. Headings and fenced blocks separate your instructions from the material, so the model does not confuse the two.
## Task
Summarise the policy below for new employees in five bullet points.
## Rules
- Plain English, no legal terms
- Mention the notice period
## Policy
```text
(paste the converted Markdown here)
```Common mistakes and how to fix them
| Problem | Fix |
|---|---|
| The model mixes up numbers from a table | The table was flattened during conversion. Rebuild it as a Markdown table or re-convert with table detection on. |
| Answers quote page headers or footers | Delete repeated header and footer lines before uploading. |
| The document is cut off or "too long" | Split at ## headings and send the relevant sections, or use a RAG setup. |
| Text from a two-column PDF reads in the wrong order | Check the converted Markdown and reorder paragraphs, or use a layout-aware tool for that file. |
| A scanned PDF converts to nothing | It has no text layer. Run OCR first, then convert the result. |
Tools for this
- PDF to Markdown Convert PDF to Markdown: Clean, Structured Text for Docs and AI
- Word to Markdown Convert Word Documents (.docx) to Clean Markdown
- URL to Markdown Convert a Web Page to Markdown from Its URL
- PowerPoint to Markdown Convert PowerPoint to Markdown Online (.pptx & .ppt to .md)
- Excel (XLSX) to Markdown Convert Excel Workbooks (.xlsx) to Markdown
- HTML to Markdown Convert HTML to Clean Markdown
- Google Docs to Markdown Convert Google Docs to Clean Markdown
- EPUB to Markdown Convert EPUB E-books to Markdown
- Jupyter (IPYNB) to Markdown Convert Jupyter Notebooks (.ipynb) to Markdown
Frequently Asked Questions About Markdown for LLMs & RAG
Comprehensive answers to common technical, formatting, security, and compatibility questions.
Related reading
- What Is Markdown? A Plain-English Explanation — What Markdown is, where it came from, where it is used and what an .md file is.
- How to Copy a Table from ChatGPT into Word, Excel or Google Docs — Three ways to move a ChatGPT table into Word, Excel, Sheets or Docs — and how to fix one-column pastes.
- Pandoc Alternative: When to Use an Online Converter, and When to Use Pandoc — An honest comparison: a browser converter versus Pandoc, with the commands for each job.