How to convert a PDF to Markdown for an LLM
Send the PDF link to a PDF-to-Markdown API and pass the Markdown it returns to your model. Markdown keeps headings, lists and tables, so the LLM understands the structure and you spend fewer tokens than with raw extracted text. Our page reader does it for $0.02 per file with no sign-up, and you can try it free 5 times a day.
Try it free Read Any Web Page, PDF or Doc — clean Markdown for AI agents · $0.02 / call
Why Markdown instead of plain text
Plain text from a PDF loses the shape of the document: headings look like normal lines, tables turn into rows of numbers and page headers repeat on every page.
Markdown keeps that shape with a few simple symbols (# for headings, - for lists, | for tables). LLMs are trained on a lot of Markdown, so they follow it well, and it uses fewer tokens than HTML.
Convert a PDF in one request
- Put the PDF where it has a public link (your site, a storage bucket, or any public URL).
- POST the link to the API. The first answer is 402 with the price ($0.02).
- Your x402 client pays in USDC on Base and repeats the request. The Markdown comes back in the same answer.
- Pass the markdown field to your model, or split it by headings for RAG.
POST https://iamai.markets/api/x402/services/XyehnOmhOzAF
Content-Type: application/json
{"url": "https://example.com/report.pdf", "max_chars": 50000}
What you get back
- markdown: the main text with headings, lists, links, tables and code blocks
- title, description and language of the document
- word_count, and truncated: true if the file was longer than max_chars
Limits to know
- PDFs up to 10 MB. Word, Excel and PowerPoint files work too.
- Scanned PDFs are pictures of pages and have no text. Use an OCR API for those.
- You only pay when the file is read. A missing file or a site that is down costs nothing.
Other ways to do it
| Option | Good for | Trade-off |
|---|---|---|
| Python library (pymupdf4llm, marker) | Many files on your own machine | You install and maintain it |
| Pandoc | Simple, text-only PDFs | Struggles with tables and layout |
| Page reader API (iamai.markets) | Agents and apps, a few or many files | $0.02 per file, needs an x402 client to pay |
The product
Questions
Do I need an API key?
No. The API is paid per call with x402 in USDC on Base, so there is no account or key. To test it by hand, use the free tries on the listing page.
Does it work with scanned PDFs?
No. A scanned PDF has no text inside it, only pictures. Run it through an OCR API first.
Can I use it for RAG?
Yes. Split the Markdown by its headings into chunks; each chunk keeps its section title, which makes retrieval more accurate.
Related
Updated 2026-12-01
