Skip to content
Tidewell Software
Document to Markdown

Convert PDF to Markdown for RAG

PDF in; Markdown and token-sized chunks out, each with page numbers and heading path.

Steps

  1. Get an API token. Apify Console → Settings → API & Integrations. Export it as APIFY_TOKEN.
  2. Install the client. pip install apify-client
  3. Add the PDF URLs. fileUrls; Drive, Dropbox and GitHub share links work.
  4. Pick chunking. tokens with size and overlap, or heading.
  5. Index the chunks. Embed text; keep page_start and heading_path as metadata.

Input

input.json
{
  "fileUrls": ["https://arxiv.org/pdf/1706.03762v7"],
  "outputFormat": "json",
  "chunking": "tokens",
  "chunkSize": 512,
  "chunkOverlap": 64,
  "pageRange": "1-3"
}

Run it

run.py
import os

from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("tidewell/doc-to-markdown").call(run_input={
    "fileUrls": [
        "https://arxiv.org/pdf/1706.03762v7"
    ],
    "outputFormat": "json",
    "chunking": "tokens",
    "chunkSize": 512,
    "chunkOverlap": 64,
    "pageRange": "1-3"
})

chunks = [
    {"id": c["chunk_id"], "text": c["text"], "page": c["page_start"], "section": " > ".join(c["heading_path"])}
    for doc in client.dataset(run["defaultDatasetId"]).iterate_items() if doc["status"] == "succeeded"
    for c in doc["chunks"]
]
print(len(chunks), chunks[0]["section"])

Output

Run on 9 November 2026: 1 document, 3 pages, $0.0029 at list price.

Dataset row (trimmed)
{
  "doc_id": "doc-0001",
  "status": "succeeded",
  "source_url": "https://arxiv.org/pdf/1706.03762v7",
  "filename": "1706.03762v7.pdf",
  "title": "Attention Is All You Need",
  "pages": 15,
  "pages_processed": 3,
  "ocr_pages": 0,
  "word_count": 1315,
  "token_count": 1799,
  "markdown_url": "https://api.apify.com/v2/key-value-stores/Q97EvdMxCu6ciudx2/records/doc-0001-1706.03762v7.md?signature=...",
  "chunk_count": 5,
  "chunks": [
    {
      "chunk_id": "doc-0001#2",
      "text": "Recent work has achieved significant improvements in computational efficiency through factorization tricks [21] and conditional computation [32], while also imp...",
      "token_count": 447,
      "page_start": 2,
      "page_end": 2,
      "heading": "1 Introduction",
      "heading_path": ["Attention Is All You Need", "1 Introduction"]
    }
  ],
  "errors": []
}

Options

outputFormat
markdown for one file per document, json for chunks
pageRange
e.g. 1-3; only those pages are billed
extractTables
Ruled PDF tables become Markdown tables
Other formats
DOCX, PPTX, XLSX, HTML, EPUB and images in the same run

Use it from Claude or ChatGPT

Apify MCP server, this actor only
https://mcp.apify.com/?tools=tidewell/doc-to-markdown
Claude
Settings → Connectors → Add custom connector. Paste the URL, sign in to Apify
Claude Code
claude mcp add apify "https://mcp.apify.com/?tools=tidewell/doc-to-markdown" -t http
ChatGPT
Add a custom MCP server with the URL and OAuth
Then ask
Use tidewell/doc-to-markdown to convert https://arxiv.org/pdf/1706.03762v7 to Markdown and summarise section 3.

Pricing

Pay per event, from the actor's live pricing on 9 November 2026.

Price
$0.002 per document + $0.0003 per page. OCR pages +$0.0027.
Free
Failed, encrypted, empty and unsupported files