mdconvert API v2.0

REST API for converting files (PDF, DOCX, DOC, RTF, ODT, EPUB, PPTX, XLSX, XLS, ODS, CSV, HTML, TXT) to Markdown and back, plus OCR for scanned PDFs. Designed for scripts and AI agents — every endpoint returns JSON. See also the agent-oriented overview. For MCP clients (Cursor, Claude Desktop), see MCP remote (Streamable HTTP at POST /mcp).

Base URL
https://mdconvert.org/api/v1
Allowed inputs: csv, doc, docx, epub, htm, html, markdown, md, mdown, ods, odt, pdf, pptx, rtf, txt, xls, xlsx Max upload: 64 MB Auth required (API key)
Authentication

Protected endpoints accept an API key in either header:

Authorization: Bearer YOUR_API_KEY
X-API-Key: YOUR_API_KEY

Each user creates their own API keys in Account (see below). GET /status and GET /download/<job>/<file> are public.

Getting an API key & first call
  1. Log in, then open Account → Generate new key. Copy it now — it is shown only once.
  2. Call the API with the key in the Authorization header:
curl -X POST https://mdconvert.org/api/v1/convert \
  -H "Authorization: Bearer mdconvert_YOUR_KEY" \
  -F "file=@document.pdf" -F "engine=pdf_autodetect" -F "language=ro"
# response JSON has download_url → fetch the .md:
curl -OJ "<download_url from response>"

CLI vs API: mdconvert_cli.py converts files locally on your machine (no key, no server). The /api/v1/ endpoints run on this remote server and need a key. Lost/compromised key? Revoke it in Account and generate a new one.

Supported conversions
Round trips
  • Word ↔ Markdown — docx → md and md → docx, both via Pandoc (the only round-trip that keeps structure).
  • Excel ↔ CSV — xlsx → csv and csv → xlsx, via pandas.
  • Markdown ↔ HTML — both directions, Pandoc.
  • Word ↔ .doc legacy — docx → doc and doc → docx, LibreOffice.

Any supported input → .txt UTF-8 (no BOM, LF newlines) and any supported input → md.

From \ To md txt docx doc csv xlsx html
pdf ✓ ✓ ✓ × × × ✓
docx ✓ ✓ — ✓ × × ✓
doc ✓ ✓ ✓ — × × ✓
md — ✓ ✓ ✓ × × ✓
txt ✓ — ✓ × × × ✓
html ✓ ✓ ✓ × × × —
pptx ✓ ✓ ✓ × × × ✓
xlsx ✓ ✓ × × ✓ — ✓
csv ✓ ✓ × × — ✓ ✓
rtf ✓ ✓ ✓ ✓ × × ✓
odt ✓ ✓ ✓ ✓ × × ✓
epub ✓ ✓ ✓ ✓ × × ✓
xls ✓ ✓ × × ✓ ✓ ✓
ods ✓ ✓ × × ✓ ✓ ✓

✓ supported  ·  × not supported  ·  — same format in and out, not a conversion

  • md ↔ docx is the only reversible conversion that preserves structure (round-trip via Pandoc). Raw HTML blocks in the Markdown (a <table> left over from an earlier docx → md pass, a <div>) are turned into native Word elements on the way back to docx. HTML output still keeps that raw HTML.
  • Table borders and a style template. Pandoc marks every table with the Word style Table. If the reference document does not define that style, Word draws the table with no borders — the usual look of a signature block. If the template's Table style has borders, those borders appear. There is no separate “borderless tables” switch.
  • .doc (Word 97 legacy): available as both input (.doc → md/txt) and output (docx → .doc, md → .doc), also via LibreOffice available — for users still delivering in the legacy format.
  • html: input → md/txt/docx; output from md/docx/txt (Pandoc), csv/xlsx (pandas), markitdown→Pandoc for pptx. mode=full inlines images/CSS on HTML output (single file, no ZIP). No remote asset fetching on HTML input.
  • rtf, odt, epub (Pandoc, --sandbox): → md/txt/html/docx (docx is a direct read, not via Markdown), and → .doc via LibreOffice. EPUB length is counted in standard pages of 2,000 characters (visible text, spaces included) on md and on docx; the free plan accepts up to 32.
  • xls, ods (pandas): → md/txt/csv/html/xlsx. Each sheet keeps its name. Formulas are copied as their stored values, never evaluated.
  • pdf → md: selectable text locally. Scanned PDFs need OCR — cloud OCR requires a credit purchase.
  • Accepted inputs include .txt, .htm (aliased to HTML), and .markdown / .mdown (aliased to md). Any other input to md falls back to markitdown.
Endpoints
MethodPathAuthRate limitPurpose
GET/statuspublic—Health + conversion matrix
POST/convertAPI key20/hConvert one file (sync or async=1). Hourly conversion cap on the principal (HOURLY_CONVERSION_CAP), same as /for-agents.
GET/convert/status/<job_id>public (UUID)—Poll async conversion
POST/convert/batchAPI key20/hConvert up to 50 files. Same hourly conversion cap as /convert (an additional 30/h decorator is looser).
POST/ocrAPI key20/hOCR a scanned PDF/image
GET/download/<job_id>/<file>public (UUID)—Download a result
GET/download/<job_id>/bundle.zippublic (UUID)—ZIP: Markdown + media/ when mode=full on a Word, RTF, ODT or EPUB → MD conversion that has pictures (has_bundle: true). Can be downloaded again; the job is deleted by the retention sweep, not by the download.
GET /status

Public health check. Lists the live conversion matrix and whether OCR is available (needs a credit pack).

curl https://mdconvert.org/api/v1/status
POST /convert

Convert a single file. Multipart form fields:

  • file — the file to convert (required)
  • target_format — md | txt | docx | csv | xlsx | doc | html (default: server setting)
  • engine — see Engines below (default: auto when omitted — server auto-selects the best engine)
  • ocr_engine — OCR sub-engine when applicable
  • language — ro | en (default: ro)
  • mode — text (default API/CLI, LLM) | full (Word / RTF / ODT / EPUB → MD: pictures extracted, ZIP with .md + media/). Web GUI always sends full.
  • async — 1 | true → return 202 immediately; poll /convert/status/<job_id> (recommended for OCR > ~60s)

HTTP errors: unsupported conversion / bad parameters → 400 (code: unsupported_conversion or bad_request). OCR could not read the document → 400 (code: ocr_no_pages). Cloud OCR temporarily unavailable → 503 (code: ocr_unavailable; retry after the Retry-After header, typically 60 seconds). Insufficient credits → 402. Server fault → 500.

curl -X POST https://mdconvert.org/api/v1/convert \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@report.docx" \
  -F "target_format=md" \
  -F "engine=pandoc" \
  -F "mode=full"

Response (JSON):

{
  "status": "ok",
  "job_id": "…",
  "output_file": "report.md",
  "download_url": "https://mdconvert.org/api/v1/download/…/report.md",
  "bundle_download_url": "https://mdconvert.org/api/v1/download/…/bundle.zip",
  "has_bundle": true,
  "mode": "full",
  "engine_used": "pandoc",
  "conversion_time_s": 1.23,
  "warnings": []
}

warnings — quality signals for this conversion, empty when there is nothing to report. Watch this one array instead of the individual reports (fidelity, pdf_layers, pdf_glyphs), which stay in the response unchanged. Each entry is {code, severity, message}; codes are stable:

  • content_missing — blocks of source text are absent from the output. On a Word source that is usually text boxes or merged table cells. On Markdown → Word, when the missing text sits inside raw HTML (a table or a div), the message names that cause. Verify against the source.
  • stacked_text_layers — the PDF has overlapping text layers we could not repair; numbers may be missing or duplicated.
  • unmapped_glyphs — symbol glyphs could not be mapped to characters; formulas may be unreadable.
  • remote_resources_skipped — remote images were linked instead of embedded, so the HTML is not self-contained.
  • images_not_embedded — Markdown → Word: some pictures are not in the .docx, only their alt text. Only data: images written into the .md are embedded; file paths and web addresses are not fetched. Markdown → HTML: some <img> still point at a local file path, so they break once the .html travels without the pictures (web addresses and data: images are fine). The top-level field images_not_embedded says how many.

New signals are added as new codes; existing codes are not renamed.

images_omitted — present when the Markdown had image references that would point at a file you do not receive (no mode=full bundle, a picture the engine does not extract, or an inline data: image). Each one is replaced in the text by [image: alt text], or [image] when the source gives none; the value is how many.

POST /convert async

For long OCR jobs, add async=1 (or header Prefer: respond-async). The server returns immediately; poll until done.

Best effort: an async job does not survive a server restart or redeploy — a poll can start returning 404. Use sync /convert when you need a guaranteed result, and re-submit if a poll stops resolving.

# 1) Start job
curl -X POST https://mdconvert.org/api/v1/convert \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@scan.pdf" -F "target_format=md" \
  -F "engine=ocr_plugin" -F "ocr_engine=mistral-ocr" \
  -F "language=ro" -F "async=1"
# → 202 {"status":"accepted","job_id":"…","poll_url":"…"}

# 2) Poll until status is ok (or error)
curl https://mdconvert.org/api/v1/convert/status/JOB_ID
Python client (recommended)

For large files and long OCR on Windows, use Python requests instead of curl (git-bash curl often fails with error 26, empty body, or HTTP 000 on multi-minute uploads).

import os, time, requests

API = "https://mdconvert.org/api/v1"
KEY = os.environ["MDCONVERT_API_KEY"]  # from Account page

with open("scan.pdf", "rb") as fh:
    r = requests.post(
        f"{API}/convert",
        headers={"X-API-Key": KEY},
        files={"file": ("scan.pdf", fh, "application/pdf")},
        data={"target_format": "md", "engine": "ocr_plugin",
              "ocr_engine": "mistral-ocr", "language": "ro", "async": "1"},
        timeout=120,
    )
poll = r.json()["poll_url"]
while True:
    s = requests.get(poll, timeout=30).json()
    if s.get("status") in ("pending", "running"):
        time.sleep(3); continue
    if s.get("status") == "ok":
        md = requests.get(s["download_url"], headers={"X-API-Key": KEY}, timeout=120)
        open("out.md", "wb").write(md.content); break
    raise RuntimeError(s)
POST /convert/batch

Same fields as /convert but send multiple files (max 50). Returns a per-file results array.

curl -X POST https://mdconvert.org/api/v1/convert/batch \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "files=@a.docx" -F "files=@b.pdf" \
  -F "target_format=md"
POST /ocr

OCR a scanned PDF to Markdown. Fields: file, ocr_engine, language, pages (e.g. 1-5 or 3,7,10-12).

curl -X POST https://mdconvert.org/api/v1/ocr \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@scan.pdf" \
  -F "ocr_engine=mistral-ocr" \
  -F "language=ro"
Conversion engines
EngineCostLocalDirectionNote
autofreeyesany → md/docx/csv/xlsxPicks the best engine automatically
pandocfreeyesdocx ↔ md; html/rtf/odt/epub → md; rtf/odt/epub → docxReversible round-trip (docx); HTML strips raw tags
markitdownfreeyesdocx/xlsx/pptx/pdf/html → mdToken-efficient, one-way
pandasfreeyesxlsx ↔ csv; xls/ods → csv/md/xlsxTabular round-trip; stored values only
pdfplumberfreeyespdf → mdText-based PDFs only
pdf_autodetectfree / $autopdf → mdpdfplumber if text, OCR if scanned
ocr_plugin$nopdf → mdCloud OCR via OpenRouter
ocr_vision$nopdf → mdPage-by-page cloud OCR

OCR sub-engines (ocr_engine): cloudflare-ai, mistral-ocr, native, ocr_vision

Cloud OCR ($ engines): available on accounts that have bought credits — free accounts get the local engines only. Priced by document size, minimum 2 credits. POST /detect quotes your ceiling up front; actual charge is never more than the quote.

Engine availability depends on the server. Call GET /status for the authoritative live list.

Python CLI equivalent: python mdconvert_cli.py convert file.pdf --to md --engine pdf_autodetect --json
PPTX → HTML (tables): python mdconvert_cli.py convert deck.pptx --to html --mode full --json