Document to Markdown & JSON for AI/RAG avatar

Document to Markdown & JSON for AI/RAG

Pricing

from $4.00 / 1,000 document converteds

Go to Apify Store
Document to Markdown & JSON for AI/RAG

Document to Markdown & JSON for AI/RAG

Convert PDF, Word (DOCX), PowerPoint (PPTX), Excel (XLSX), HTML web pages, EPUB and text files into clean Markdown, plain text and metadata, with tables as Markdown and RAG-ready chunks with token counts and page numbers. Optional OCR.

Pricing

from $4.00 / 1,000 document converteds

Rating

0.0

(0)

Developer

Arpit Goriya

Arpit Goriya

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

3 hours ago

Last modified

Features

Limited permissions

Share

Convert PDF, Word (DOCX), PowerPoint (PPTX), Excel (XLSX), CSV, EPUB, HTML web pages, Markdown and text files into clean Markdown, plain text and metadata, ready for LLMs, RAG pipelines and AI agents. Tables come out as Markdown tables, and each document can be split into RAG-ready chunks with token counts, heading paths and page numbers. Optional OCR reads scanned PDFs and images. You pay a fixed price per converted document, and failed documents are free.

What does Document to Markdown & JSON do?

You give it links to documents or web pages (or files in your Apify storage). For each one it downloads the file, detects the format from its content, and returns one dataset row with:

  • 📝 the full document as Markdown: headings, lists, bold/italic, tables as Markdown tables;
  • 📄 the same content as plain text;
  • 🧩 RAG chunks (optional): each chunk has its text, token count (OpenAI cl100k_base), heading path (e.g. ["3 Model Architecture", "3.2 Attention"]) and page range;
  • 🏷️ metadata: title, author, language, page/slide/sheet count, word and token counts, created/modified dates, and for web pages the site name, publish date and description;
  • ⚠️ clear warnings and errors, for example "page 4 has no text layer; turn on OCR".

Run it from the Apify Console with no code, on a schedule, through the API, from Make, Zapier or n8n, or from an AI agent through the Apify MCP server.

Why use it?

  • One tool for every common format. PDF, DOCX, PPTX (with speaker notes and chart data), XLSX (every sheet), CSV, EPUB, HTML, Markdown, TXT and JSON, plus PNG/JPEG/TIFF/WebP images with OCR. The format is detected from the file content, so URLs without an extension work.
  • Clean text for embeddings. Repeated page headers, footers and page numbers are removed from PDFs, broken words are re-joined ("exam-ple" → "example"), rotated margin text is dropped, and web pages keep only the main content (no menus, cookie banners or footers).
  • Structure that survives. Headings are detected in PDFs from font sizes and numbering ("3.2 Results"), so chunks follow the document's sections. Ruled tables and "booktabs" tables (typical in papers and reports) become Markdown tables.
  • RAG-ready chunks. Heading-aware chunking with exact token counts, overlap, heading paths and page numbers, so you can cite the source page in your answers. Big tables are split by rows with the header repeated.
  • Predictable price. $4 per 1,000 documents, no start fee, compute included. OCR is off by default and charged per page only when you turn it on.
  • Fast. A 15-page research paper converts in about 3 seconds.

Use cases

  • RAG and chatbots: turn PDFs, policies, manuals and help-center pages into chunks for Pinecone, Qdrant, Weaviate, pgvector, Chroma or any vector database.
  • AI agents: give an agent a tool that reads any document link and returns Markdown it can reason over.
  • LLM fine-tuning and evaluation data: bulk-convert reports, papers and e-books into clean text.
  • Search and knowledge bases: index office documents and web pages with titles, languages and page anchors.
  • Back-office automation: extract text and tables from invoices, statements or forms (scanned ones with OCR) for further processing.

How to use it

  1. Click Try for free (or Start).
  2. Paste links into Document or web page URLs, or upload a file.
  3. Pick a RAG chunking mode and chunk size if you need chunks. Turn on OCR mode: Auto if some PDFs are scanned.
  4. Click Start. Open the Output tab to see each document, or export the dataset as JSON, CSV or Excel.

Input example

{
"startUrls": [
{ "url": "https://arxiv.org/pdf/1706.03762" },
{ "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation" },
{ "url": "https://calibre-ebook.com/downloads/demos/demo.docx" }
],
"chunking": "inline",
"chunkSize": 512,
"chunkOverlap": 64,
"ocrMode": "off"
}

Files that are already in Apify storage (for example the output of another Actor):

{
"keyValueStoreId": "my-documents",
"keyValueStoreKeys": ["contract.pdf", "slides.pptx"],
"ocrMode": "auto",
"chunking": "separate"
}

All input options

OptionWhat it doesDefault
startUrlsLinks to documents or web pages (list, pasted text or uploaded URL list)—
uploadedFileUpload one file from your computer—
keyValueStoreId / keyValueStoreKeysConvert records from your key-value store (all records if no keys are given)—
chunkinginline (chunks inside each document row), separate (one row per chunk) or noneinline
chunkSize / chunkOverlapMax tokens per chunk / tokens repeated between consecutive chunks512 / 64
headingAwareChunkingStart a new chunk at each headingtrue
ocrModeoff, auto (only pages without a text layer, and images) or alwaysoff
ocrLanguagesTesseract languages, e.g. eng+deu. Available: eng, deu, fra, spa, por, ita, nld, pol, hineng
includeMarkdown / includePlainTextInclude the markdown / text fieldstrue / true
includeTablesConvert tables to Markdown tablestrue
pageMarkersInsert <!-- page N --> comments into the Markdownfalse
removeHeadersFootersRemove repeated PDF headers, footers and page numberstrue
htmlExtractionmain (article content only) or full (whole page)main
includeLinksKeep hyperlinks as [text](url)false
includeSpeakerNotesAdd PPTX speaker notestrue
saveMarkdownFilesAlso save each document as a .md file with a download linkfalse
maxPagesPerDocumentMax PDF pages converted per document1000
maxRowsPerSheetMax rows per XLSX sheet / CSV5000
maxFileSizeMbSkip files larger than this100
maxConcurrencyParallel downloads4
proxyConfigurationOptional Apify Proxy for sites that block data-center IPsoff

Output example

One row per document (shortened; real output from the input example above):

{
"itemType": "document",
"url": "https://arxiv.org/pdf/1706.03762",
"format": "pdf",
"success": true,
"title": "Attention Is All You Need",
"language": "en",
"pageCount": 15,
"pageUnit": "page",
"wordCount": 6220,
"tokenCount": 9568,
"tableCount": 4,
"headingCount": 27,
"ocrPages": 0,
"markdown": "# Attention Is All You Need\n\n...\n\n## Abstract\n\nThe dominant sequence transduction models are based on complex recurrent or convolutional neural networks ...\n\n### 3.5 Positional Encoding\n...\n\n| Layer Type | Complexity per Layer | Sequential | Maximum Path Length |\n| --- | --- | --- | --- |\n| Self-Attention | O(n2 · d) | O(1) | O(1) |\n| Recurrent | O(n · d2) | O(n) | O(n) |\n...",
"text": "Attention Is All You Need\n\n...",
"chunkCount": 29,
"chunks": [
{
"chunkIndex": 1,
"text": "## Abstract\n\nThe dominant sequence transduction models are based on complex recurrent or convolutional neural networks ...",
"tokenCount": 430,
"charCount": 2232,
"headings": ["Attention Is All You Need", "Abstract"],
"pageStart": 1,
"pageEnd": 1
}
],
"metadata": {
"creator": "LaTeX with hyperref",
"producer": "pdfTeX-1.40.25",
"createdAt": "2024-04-10T21:11:43Z",
"modifiedAt": "2024-04-10T21:11:43Z"
},
"warnings": [],
"error": null
}

With "chunking": "separate", each chunk is also written as its own row ("itemType": "chunk") with the document's url, title, format and language, so you can import the dataset straight into a vector database. Failed documents get a row with "success": false and an error message, and are not charged.

How much does it cost to convert documents?

Pay per event. Platform compute is included, there is no start fee, and failed documents are free.

EventWhen it is chargedPrice
document-convertedA document was converted (includes up to 50 PDF pages)$0.004 ($4 per 1,000 documents)
extra-pageEach PDF page after the first 50 of a document$0.0001 ($0.10 per 1,000 pages)
page-ocrEach page or image read with OCR (only when OCR mode is on)$0.005

Examples:

  • 1,000 web pages, Word files or PDFs of up to 50 pages: $4.00.
  • One 300-page PDF: $0.004 + 250 × $0.0001 = $0.029.
  • A 10-page scanned PDF with OCR: $0.004 + 10 × $0.005 = $0.054.

Your Maximum cost per run setting is always respected: documents (and OCR pages) that would go over it are skipped instead of started, and the run finishes normally with a message saying so. On the Apify free plan you can try it with your monthly free credits.

Call it from the API

Run synchronously and get the results in one request (replace YOUR_TOKEN):

curl -X POST "https://api.apify.com/v2/acts/arpitgoriya~document-to-markdown/run-sync-get-dataset-items?token=YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"startUrls":[{"url":"https://arxiv.org/pdf/1706.03762"}],"chunking":"inline","chunkSize":512}'

Python (apify-client), feeding chunks into your own vector store:

from apify_client import ApifyClient
client = ApifyClient("YOUR_TOKEN")
run = client.actor("arpitgoriya/document-to-markdown").call(run_input={
"startUrls": [{"url": "https://example.com/handbook.pdf"}],
"chunking": "separate",
"chunkSize": 400,
"chunkOverlap": 50,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
if item["itemType"] == "chunk":
# item["text"], item["headings"], item["pageStart"], item["url"]
...

JavaScript (apify-client):

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('arpitgoriya/document-to-markdown').call({
startUrls: [{ url: 'https://calibre-ebook.com/downloads/demos/demo.docx' }],
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].markdown);

Use it from AI agents (MCP)

This Actor is available as a tool through the Apify MCP server, so Claude, ChatGPT, Cursor, VS Code, n8n and any other MCP client can call it directly. The input schema becomes the tool's parameters automatically.

{
"mcpServers": {
"document-to-markdown": {
"url": "https://mcp.apify.com?tools=arpitgoriya/document-to-markdown"
}
}
}

Or locally: npx -y @apify/actors-mcp-server --tools arpitgoriya/document-to-markdown.

Then ask, for example: "Read this PDF and summarize section 3: https://arxiv.org/pdf/1706.03762". For agents, set "chunking": "none" and "includePlainText": false to keep the response small.

Supported formats

FormatWhat you get
PDF (text-based)Headings (font size + numbering), paragraphs, bullet lists, ruled and booktabs tables, metadata. Multi-column layouts are usually read in column order (layout analysis by pdfminer.six).
PDF (scanned)With OCR mode auto/always: text via Tesseract, per page.
DOCXHeadings (Title, Heading 1–6), bold/italic, lists, tables (merged cells handled), links (optional), core properties.
PPTXOne section per slide with its title, text boxes in reading order, bullet levels, tables, chart data as tables, speaker notes.
XLSX / CSVOne Markdown table per sheet (calculated values, dates in ISO format), empty rows/columns trimmed.
HTML / web pagesMain content (trafilatura) or the whole page, tables, metadata (title, author, date, site name, description, language).
EPUBChapters in reading order with headings, lists and metadata.
Markdown, TXT, JSONCleaned and split into blocks; JSON pretty-printed.
Images (PNG, JPEG, TIFF, WebP, BMP, GIF)With OCR mode on: text via Tesseract (multi-page TIFF supported).

Not supported: legacy binary Office files (DOC, XLS, PPT), RTF and OpenDocument (ODT/ODS/ODP). Save them as DOCX/XLSX/PPTX or PDF first. Web pages that need JavaScript to show their text, or a login, are not supported.

FAQ

My PDF gave "No text found". It is scanned (an image of text). Set OCR mode to Auto. Only pages without a text layer are OCR'd and charged.

How good is table extraction from PDFs? Tables drawn with lines (grids) and tables with horizontal rules only (common in papers and financial reports) are detected. Tables laid out with spaces only and no rules stay as text. Complex merged headers may need a manual check.

Which tokenizer is used for chunk sizes? OpenAI's cl100k_base (text-embedding-3-small/large, GPT-4). Other tokenizers give similar counts for English text, so leave some headroom below your embedding model's limit.

Are math formulas kept? Text-based formulas are kept as plain characters (e.g. O(n2 · d)); they are not converted to LaTeX.

Is my data stored? Documents are processed in your own Apify run. Results stay in your run's dataset and key-value store under your account's data retention settings. Nothing is sent to third-party AI services.

Can I convert files behind a login? Not directly. Upload the file, put it in a key-value store, or give a pre-signed URL (S3, Google Cloud Storage, Dropbox ?dl=1 links all work).

How big can files be? Up to 500 MB (maxFileSizeMb, 100 MB by default). Very long results are saved to the key-value store as a .md file, and the row links to it.

Open source and credits

Built on permissively licensed open-source software: pdfplumber and pdfminer.six (MIT), pypdfium2/PDFium (Apache-2.0/BSD), python-docx, python-pptx, openpyxl (MIT), trafilatura (Apache-2.0), markdownify and Beautiful Soup (MIT), tiktoken (MIT) and Tesseract OCR (Apache-2.0).

Other tools from us

Feedback and support

Found a document that doesn't convert well, or need a format? Open an issue on the Issues tab with a link to a sample file. We read every issue and reply as quickly as we can.