How to fix “context window exceeded” in ChatGPT and Claude

You upload a PDF, ask one question, and the model tells you the conversation is too long — or quietly forgets the first half of the document. The file isn't too big. It's too expensive in tokens, and most of those tokens are avoidable.

Why a 5 MB PDF can overflow a 200K context window

Context windows are measured in tokens, not megabytes. A dense, text-heavy PDF can produce far more tokens than a much larger image-heavy one — and native PDF upload makes it worse. When you attach a PDF directly, the model typically processes each page as extracted text plus a page image. Measured with Anthropic’s own token counter, that overhead runs 1,694–1,878 tokens per page. On a 100-page document it is 169,000–188,000 tokens — before a single word of your question.

Worse: attached files are re-read on every turn of the conversation. That overhead isn't paid once, it's paid each time you ask a follow-up — which is why long document chats degrade and eventually hit the wall.

The fix, in order of impact

  1. Convert the document to Markdown before you paste it.Plain Markdown carries the same words with none of the format overhead. Across our test corpus, converting PDFs cut token usage by 71–84% versus native PDF upload.
  2. Strip the boilerplate.Repeated page headers, footers, page numbers, and navigation chrome are pure noise. Milldown's Clean Up pass removes them without touching the content.
  3. Split by headings, not by page count.If the document still doesn't fit, split the Markdown at its heading structure so each chunk is a self-contained section. Feeding a model half a table is worse than feeding it one whole chapter.
  4. Send only the sections the question needs.For a contract question about termination clauses, the model doesn't need the appendices. Markdown makes documents skimmable and croppable in a way PDFs never are.
  5. Start a fresh chat when the topic changes.A 150-page document lingering in history taxes every later message. New topic, new conversation.

Measured locally. Milldown counts tokens locally with OpenAI’s o200k tokenizer — an estimate, since each provider tokenizes slightly differently, but a consistent one. On our benchmark corpus: PDFs drop 71–84% versus native upload and web pages 72–95% versus raw HTML. Word and PowerPoint show no saving at all. The badge shows the real number for each file you convert.

What about prompt caching?

One caveat: if you use the API with prompt caching, repeated reads of the same attachment get much cheaper, so the dollar savings of conversion shrink on later turns. What doesn't shrink is the context-window saving — a cached PDF still occupies the same enormous slice of the window. If your problem is “conversation too long” rather than cost, Markdown remains the fix.

Doing this on a Mac

Milldown converts PDFs, Word, PowerPoint, Excel, EPUB, and web pages to clean Markdown entirely on your Mac — nothing is uploaded, and scanned PDFs are OCR’d on-device. Drop the file, watch the token badge, copy the result into ChatGPT or Claude. See the format guides for specifics: PDF, Word, scanned PDFs.

Stop feeding your AI page furniture

Convert documents to clean, token-efficient Markdown — entirely on your computer. Free for 7 days.

Download for macOS

macOS 14+ · Apple Silicon · $39 one-time after trial (excl. VAT) · no subscription