MDConverter
Universal In-Browser Converter
100% Client-Side Private

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.

The same content as HTML (575 characters) and Markdown (227 characters)
Markdown
## 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 time
Result

Pricing

All plans include unlimited projects.

Plan Price Seats
Starter $9 1
Team $29 10
Business $99 50
Generated by our HTML to Markdown converter from a <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

  1. Remove page furniture. Repeated headers, footers, page numbers and "Confidential — do not distribute" lines add noise to every chunk.
  2. Fix heading levels. One # title, then ## sections and ### sub-sections. Models and chunkers use these as boundaries.
  3. 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.
  4. Describe images that matter. Converters keep image alt text, not the picture. Add a sentence for any chart or diagram the answer depends on.
  5. Delete boilerplate. Legal disclaimers, tables of contents and cover pages rarely help and cost tokens.
  6. 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.

A prompt structured with Markdown
Markdown
## 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)
```
Fencing the pasted document in a code block stops headings inside it from being read as part of your instructions.

Common mistakes and how to fix them

ProblemFix
The model mixes up numbers from a tableThe table was flattened during conversion. Rebuild it as a Markdown table or re-convert with table detection on.
Answers quote page headers or footersDelete 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 orderCheck the converted Markdown and reorder paragraphs, or use a layout-aware tool for that file.
A scanned PDF converts to nothingIt has no text layer. Run OCR first, then convert the result.

Tools for this

Frequently Asked Questions

Frequently Asked Questions About Markdown for LLMs & RAG

Comprehensive answers to common technical, formatting, security, and compatibility questions.

Usually, yes. Both can read PDFs directly, but they have to extract the text first, and you cannot see what they extracted. Converting to Markdown yourself shows you the exact text the model will read, keeps headings and tables, and uses fewer tokens. For a short, simple PDF the difference is small; for long or table-heavy documents it is significant.

Sources

← All guides