# Markdown vs raw PDF for LLM context: the token math

> Feeding a raw PDF to an LLM costs 60–90% more tokens than converting it to Markdown first. Here's the arithmetic, why it happens, and when the conversion pays for itself.

Published: 2026-07-07 · Source: https://marklipi.com/blog/markdown-vs-pdf-llm-token-costs


Converting a PDF to Markdown before sending it to an LLM typically cuts token usage by 60–90% compared to sending the PDF directly to a vision-capable model. For a pipeline processing thousands of documents, that difference is the difference between a rounding error and a real cloud bill.

## Why raw PDFs are expensive in tokens

When you attach a PDF to a model request, one of two things happens under the hood:

1. **Page-as-image processing.** Vision models rasterize each page and consume it as image tokens. A single page commonly costs on the order of 1,500–3,000 tokens *as pixels*, regardless of how little text is on it. A mostly-empty cover page costs nearly as much as a dense one.
2. **Embedded text extraction plus layout noise.** Some providers extract text server-side, but PDF text comes with artifacts — headers and footers repeated on every page, hyphenated line breaks, out-of-order text runs from multi-column layouts — that inflate the token count and degrade answers.

Markdown avoids both. It carries only the content, structure survives as headings and tables, and the model reads it natively with no vision step.

## The arithmetic on a real document shape

Take a 20-page bank statement — the kind of document agents process constantly:

| Approach | Rough token cost | Notes |
| -------- | ---------------- | ----- |
| PDF as images to a vision model | ~30,000–60,000 tokens | ~1,500–3,000 image tokens × 20 pages |
| Extracted raw text, unclean | ~12,000–18,000 tokens | repeated headers/footers, broken lines |
| Converted to Markdown | ~6,000–10,000 tokens | content only, tables intact |

That's the 60–90% range in practice: Markdown lands at roughly a tenth to a third of the vision-model cost, and meaningfully under naive text extraction because the repetitive furniture is gone.

Multiply it out: at 10,000 documents a month, moving from ~40k tokens/doc to ~8k tokens/doc saves ~320 million input tokens monthly. Price that at your model's input rate and the conversion step pays for itself immediately — especially when the conversion is [a free API call](/blog/convert-pdf-to-markdown-python-node-curl).

## Tokens aren't the only win

- **Tables stay tables.** A Markdown table is something a model can reason over row by row. The same table as pixels invites transcription errors on exactly the fields you care about — dates, amounts, account numbers.
- **Deterministic input.** Text-layer extraction produces the same Markdown every run. Vision-model reads of the same page can vary between runs, which makes downstream bugs miserable to reproduce.
- **Chunking for RAG.** Markdown headings give you natural chunk boundaries. Raw PDF text gives you page breaks, which cut mid-sentence and mid-table.
- **Cheaper retries.** Agents re-read documents constantly — every retry, every follow-up question re-pays the input token cost. A small document representation compounds.

## When raw PDF input is still the right call

Honesty matters here: if the PDF is a **scan or a photo**, there is no text layer to extract, and a vision model (or an OCR pipeline) is the correct tool — [here's how to tell which kind of PDF you have](/blog/pdf-text-layer-vs-ocr). Layout-heavy documents where visual position *is* the meaning (complex forms, engineering drawings) can also justify vision processing. For everything digital-native — statements, contracts, filings, exports, invoices — text-layer extraction to Markdown is faster, cheaper, and more accurate.

## FAQ

### Where does the 60–90% figure come from?

The low end (60%) is Markdown versus unclean extracted text on documents with heavy repeated furniture. The high end (90%+) is Markdown versus page-as-image vision processing on multi-page documents. Your exact number depends on page density and pipeline, which is why the table above shows ranges, not a single figure.

### Does converting to Markdown lose information?

For text-layer PDFs, the content and structure (headings, tables, lists) survive. What you lose is visual styling — fonts, colors, absolute positioning — which LLMs don't use anyway.

### How do I convert PDFs to Markdown in my pipeline?

One HTTP request, no key: `curl -s https://api.marklipi.com/convert -F "file=@doc.pdf"`. Examples in Python and Node are in [the how-to guide](/blog/convert-pdf-to-markdown-python-node-curl), or try it in the browser with the [free converter](/pdf-to-markdown).

