What a token is
Language models don't read letters or whole pages. They read tokens: short pieces of text,
often a common word or part of a longer one. The sentence Hello world, this is a test. is 8
tokens for OpenAI's GPT-4o tokenizer.
Everything you send is counted: the words, and also every tag, bracket, attribute and stray space around them. That matters for three reasons:
- Cost. AI APIs charge by the token, for what you send and for what comes back.
- Room. Every model has a limit on how much it can read at once (its context window). Wasted tokens push useful text out, or stop a long document from fitting at all.
- Speed. More tokens take longer to process.
Where tokens get wasted
Most documents carry far more than their words. To a language model, all of it is tokens.
Web pages
HTML wraps every sentence in tags, classes and attributes, and pages add menus, scripts and footers. When Cloudflare measured one of its own blog posts, it came to 16,180 tokens as HTML and 3,150 tokens as Markdown: about 80% less.1
Word files
A .docx file is a zip of XML files. The text sits inside markup that describes fonts, spacing
and runs of formatting. In our sample report, the main XML part alone is 1,808 tokens for content that
needs 137 tokens as Markdown.
PDFs
When you send a PDF to Anthropic's Claude, every page is turned into an image and its text is extracted and sent alongside. Anthropic estimates 1,500 to 3,000 tokens per page, with the page images counted on top.3 OpenAI's API also sends the extracted text plus an image of every page, and warns that this can increase token usage.4 That is worth it when the layout or a chart matters, and wasted when you only need the words.
Scans and phone photos
A picture of a page has no text at all until something reads it. Sending the image means paying for vision on every page, every time you ask a question about it.
Why Markdown works so well
The markup is tiny. A heading is #, a list item is -, bold text
is **, a table is a few | characters. A heading costs a token or two of markup
instead of an opening tag, a closing tag and attributes.
The structure survives. Headings, lists and tables come through, so the model can tell a title from a footnote and knows which number sits in which column. Bare text is a little shorter (111 tokens against 137 in our sample) but loses the table and every heading.
Models already speak it. AI assistants write their own answers in Markdown, and it fills the
documentation and code repositories they learned from. The llms.txt proposal, a standard way for websites to
describe themselves to AI, chose Markdown because it is the most widely and easily understood format for
language models
.5 Cloudflare now serves Markdown
to AI agents automatically for the same reason.2
People can read it too. You can check and fix exactly what the model will see before you send it.
Format is not magic. A Microsoft and MIT study found that the best prompt format depends on the model and the task.6 Markdown's dependable win is fewer tokens and clean structure, not guaranteed better answers.
How much it saves: real numbers
We took one of the documents from Dox2MD's test suite, a one-page pilot study report with a title, headings, a numbered list, a bullet list and a table, and counted the tokens of the same content in five forms.
| Same document as | Tokens |
|---|---|
| Saved as a web page (HTML export) | 1,913 |
| Raw XML inside the Word file | 1,808 |
| Clean, minimal HTML | 333 |
| Dox2MD Markdown | 137 |
| Bare text, structure removed | 111 |
Markdown used 93% fewer tokens than the document saved as a web page (1,913 down to 137), and 59% fewer than even clean, minimal HTML (333), while keeping every heading, list item and table cell.
PDFs show the same pattern. Our three-page sample PDF report becomes 411 tokens of Markdown. Sent as a PDF, Anthropic's estimate for three pages is 4,500 to 9,000 tokens, before the page images are counted.
One document is not a benchmark: the saving depends on how much markup and layout the original
carries. Other models use their own tokenizers, so their exact counts will differ. The files and the script
we used are in the project's docs/token-measurement.md, so the test can be repeated.
How Dox2MD turns documents into Markdown
It checks the file
The real type is recognised from the content, not the name. Size and page limits are applied, and files built to harm servers are refused.
It reads the text
PDFs, Word and ODT files are read directly, along with font sizes, bold text and positions. Scanned pages and photos are cleaned up first (cropped, shadows evened out, turned upright) and then read with OCR.
It rebuilds the structure
Headings are found from size and weight, lists and tables are rebuilt, and lines broken by the page layout are joined back together.
It writes clean Markdown
You get a preview, the editable Markdown and a count of words, headings, tables and tokens, with a warning when a scanned page was hard to read.
It forgets the file
Everything happens in memory. The file is not stored, logged or used for training.
It also works the other way: give it Markdown and it lays out a finished PDF report, CV, letter or general document.
Getting the most out of it
- Paste it or attach it. Paste the Markdown straight into the chat, or download the
.mdfile and attach it. - Keep the headings. They let you ask about one part, such as the Results section, and help the model find it.
- Check numbers from scans. OCR is very good but not perfect. Dox2MD shows a confidence score and warns you about difficult pages.
- Split very long documents. If a document still doesn't fit, send it section by section.
- Send the picture when the picture matters. For charts and diagrams, add the image alongside the Markdown.
Try it on one of your own documents. It's free, needs no account, and your file is never stored.
Sources
- Cloudflare’s Markdown for Agents (The New Stack, February 2026)
- Markdown for Agents (Cloudflare documentation)
- PDF support (Anthropic Claude documentation)
- PDF files (OpenAI API documentation)
- The /llms.txt file, a proposal by Jeremy Howard (Answer.AI, 2024)
- He et al., “Does Prompt Formatting Have Any Impact on LLM Performance?” (Microsoft and MIT, 2024)