PDF to Markdown & RAG Chunks avatar

PDF to Markdown & RAG Chunks

Pricing

from $0.20 / 1,000 page converteds

Go to Apify Store
PDF to Markdown & RAG Chunks

PDF to Markdown & RAG Chunks

Convert PDFs from URLs into clean, LLM-ready Markdown (headings, lists, paragraphs; headers, footers and page numbers removed) and optional RAG chunks with overlap, page numbers and heading context.

Pricing

from $0.20 / 1,000 page converteds

Rating

0.0

(0)

Developer

Cyd Dunscombe

Cyd Dunscombe

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

9 hours ago

Last modified

Share

Turn PDFs into clean, LLM-ready Markdown and ready-to-embed RAG chunks: paste PDF links, get structured Markdown with headings, lists and paragraphs, with running headers, footers and page numbers removed. Each chunk comes with its page range and section path, so your answers can cite the right page.

No API keys, no OCR setup, no Python. Pages are processed in about a second per 50 pages.

How to convert PDF to Markdown in 3 steps

  1. Paste PDF links into PDF URLs.
  2. Choose the output: full Markdown per document, RAG chunks, or both.
  3. Click Start. Markdown and chunks appear in the Output tab, and each document is also saved as a .md file you can download.

What it's for

  • RAG / vector databases: feed chunks straight into Pinecone, Qdrant, Weaviate, pgvector, LangChain or LlamaIndex. Each chunk carries headings (the section path it sits under) and pageStart/pageEnd for citations.
  • LLM context: give ChatGPT, Claude or your own agent a clean Markdown version of a paper, contract, manual, filing or report instead of a garbled copy-paste.
  • Knowledge bases: convert policy documents, product manuals or research papers in bulk and store the .md files.
  • Automation: call it from Make, Zapier, n8n or the Apify API whenever a new PDF shows up.

What you get

HeadingsDetected from font size and bold text, mapped to #–####. Numbered sections (1, 1.1, 1.1.1) keep their numbers.
ParagraphsLines re-joined into real paragraphs, words split by line-end hyphens re-joined, ligatures (fi, fl) fixed. Two-column layouts are read column by column.
ListsBulleted and numbered lists become Markdown lists.
Noise removedRunning headers and footers (text repeated at the top or bottom of many pages), page numbers, "Page 3 of 40", rotated margin stamps.
MetadataTitle, author, subject, keywords, creator, producer, creation and modification dates, page count, word count, approximate token count.
ChunksSection-aware chunks of your chosen size with overlap, page range and heading path.

Input

{
"pdfUrls": [
"https://arxiv.org/pdf/1706.03762",
"https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.100-1.pdf"
],
"outputMode": "both",
"chunkSize": 2000,
"chunkOverlap": 200
}
FieldDefaultNotes
pdfUrls–Direct links to PDF files. Redirects are followed.
outputModedocumentdocument (one row per PDF), chunks (one row per chunk) or both.
chunkSize2000Max characters per chunk (≈ 500 tokens). 200–20,000.
chunkOverlap200Characters repeated from the previous chunk, cut at a sentence/word boundary. Not added across sections.
maxPages0 (all)Convert only the first N pages of each PDF.
removeHeadersFooterstrueRemove running headers, footers and page numbers.
includePageMarkersfalseInsert <!-- page N --> comments.
saveMarkdownFiletrueSave each document as a .md file in the key-value store.
maxFileSizeMb50Larger files are skipped (not charged). Up to 200.

Your own files: upload them to an Apify key-value store (or any file host, S3, Google Drive public link that serves the raw file) and paste the links.

Output

Document row (type: "document")

{
"type": "document",
"url": "https://arxiv.org/pdf/1706.03762",
"fileName": "1706.03762v7.pdf",
"status": "ok",
"title": "Attention Is All You Need",
"author": null,
"createdAt": "2024-04-10T21:11:43.000Z",
"pageCount": 15,
"pagesConverted": 15,
"charCount": 38447,
"wordCount": 5880,
"approxTokens": 9612,
"markdownUrl": "https://api.apify.com/v2/key-value-stores/…/records/1706.03762v7-dd93e904.md",
"markdown": "…\n\n# Attention Is All You Need\n\n…\n\n## Abstract\n\nThe dominant sequence transduction models…",
"chunkCount": 27
}

Chunk row (type: "chunk")

{
"type": "chunk",
"url": "https://arxiv.org/pdf/1706.03762",
"title": "Attention Is All You Need",
"chunkIndex": 7,
"chunkCount": 27,
"headings": ["Attention Is All You Need", "3 Model Architecture"],
"pageStart": 4,
"pageEnd": 4,
"charCount": 1553,
"approxTokens": 389,
"text": "### 3.2.1 Scaled Dot-Product Attention\n\nWe call our particular attention \"Scaled Dot-Product Attention\"…"
}

Use the Documents and Chunks views in the dataset tab, or filter by type in the API. A RUN_SUMMARY record in the key-value store lists every PDF with its status.

Statuses

ok · failed (download error, HTTP 404 etc.) · not-pdf (the link returns a web page) · too-large · encrypted (password-protected) · invalid-pdf (corrupt file) · no-text-layer (scanned or image-only, OCR not supported yet) · blocked (private or internal address) · skipped (your max charge for the run was reached). Only ok documents are charged.

Pricing

Pay per event, no subscription:

EventPrice
PDF converted$0.002
Page converted$0.0002

A 15-page paper costs $0.005. A 100-page report costs $0.022. 1,000 ten-page documents cost $4.

You are never charged for failed, blocked, password-protected, too-large or scanned PDFs. If you set a maximum charge for the run, the Actor stops cleanly at that limit: the last document may be truncated (truncatedByChargeLimit: true) and remaining documents are marked skipped.

Integrations and API

  • Make, Zapier, n8n: start the Actor when a new PDF link arrives (email, Drive, form) and send the Markdown or chunks to your vector database, Notion or Google Docs.
  • LangChain / LlamaIndex: read the dataset with the Apify loaders, or with the API client below.
  • API / code:
curl -X POST "https://api.apify.com/v2/acts/datacolada~pdf-to-markdown-rag/run-sync-get-dataset-items?token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"pdfUrls":["https://arxiv.org/pdf/1706.03762"],"outputMode":"chunks","chunkSize":2000}'
from apify_client import ApifyClient
client = ApifyClient("YOUR_API_TOKEN")
run = client.actor("datacolada/pdf-to-markdown-rag").call(run_input={
"pdfUrls": ["https://arxiv.org/pdf/1706.03762"],
"outputMode": "chunks",
})
for chunk in client.dataset(run["defaultDatasetId"]).iterate_items():
print(chunk["pageStart"], " > ".join(chunk["headings"]), chunk["text"][:80])

Tips

  • For RAG, chunkSize 1500–3000 with chunkOverlap 150–300 works well for most embedding models.
  • Prepend headings.join(" > ") to each chunk before embedding for better retrieval.
  • Use maxPages to preview a large document cheaply.
  • Very long documents: the full Markdown is always in the .md file (markdownUrl). Inline markdown is cut at 1.5M characters (markdownTruncated: true).

Limitations

  • Scanned PDFs (images without a text layer) are detected and skipped without charge; OCR is not included.
  • Tables are output as text lines, not Markdown tables.
  • Math formulas come out as their Unicode text, not LaTeX.
  • Heading detection is based on fonts; unusual layouts (posters, slides, forms) may produce fewer headings.

FAQ

Does it work on scanned PDFs? Not yet. PDFs without a text layer are detected, marked no-text-layer and not charged.

Can I convert my own files? Yes. Upload them to an Apify key-value store or any host that serves the raw PDF, and paste the links.

What chunk size should I use? 1,500 to 3,000 characters with 150 to 300 overlap suits most embedding models. Each chunk keeps its page range and section headings for citations.

How much does it cost? $0.002 per PDF plus $0.0002 per page converted. A 15-page paper costs $0.005. Failed, encrypted, scanned and too-large files are free.

Are tables converted? Tables come out as text lines, not Markdown tables, for now.

Changelog

  • 0.1.3: README FAQ and API examples.
  • 0.1: first release.