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).
https://mdconvert.org/api/v1Protected 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.
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.
docx → md and md → docx, both via Pandoc (the only round-trip that keeps structure).xlsx → csv and csv → xlsx, via pandas.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 |
|---|---|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | × | × | × | ✓ | |
| docx | ✓ | ✓ | — | ✓ | × | × | ✓ |
| doc | ✓ | ✓ | ✓ | — | × | × | ✓ |
| md | — | ✓ | ✓ | ✓ | × | × | ✓ |
| txt | ✓ | — | ✓ | × | × | × | ✓ |
| html | ✓ | ✓ | ✓ | × | × | × | — |
| pptx | ✓ | ✓ | ✓ | × | × | × | ✓ |
| xlsx | ✓ | ✓ | × | × | ✓ | — | ✓ |
| csv | ✓ | ✓ | × | × | — | ✓ | ✓ |
| rtf | ✓ | ✓ | ✓ | ✓ | × | × | ✓ |
| odt | ✓ | ✓ | ✓ | ✓ | × | × | ✓ |
| epub | ✓ | ✓ | ✓ | ✓ | × | × | ✓ |
| xls | ✓ | ✓ | × | × | ✓ | ✓ | ✓ |
| ods | ✓ | ✓ | × | × | ✓ | ✓ | ✓ |
✓ supported · × not supported · — same format in and out, not a conversion
<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. 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.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.--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.md/txt/csv/html/xlsx. Each sheet keeps its name. Formulas are copied as their stored values, never evaluated..txt, .htm (aliased to HTML), and .markdown / .mdown (aliased to md). Any other input to md falls back to markitdown.| Method | Path | Auth | Rate limit | Purpose |
|---|---|---|---|---|
| GET | /status | public | — | Health + conversion matrix |
| POST | /convert | API key | 20/h | Convert 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/batch | API key | 20/h | Convert up to 50 files. Same hourly conversion cap as /convert (an additional 30/h decorator is looser). |
| POST | /ocr | API key | 20/h | OCR a scanned PDF/image |
| GET | /download/<job_id>/<file> | public (UUID) | — | Download a result |
| GET | /download/<job_id>/bundle.zip | public (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. |
/statusPublic health check. Lists the live conversion matrix and whether OCR is available (needs a credit pack).
curl https://mdconvert.org/api/v1/status
/convertConvert 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 applicablelanguage — 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.
/convert asyncFor 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
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)
/convert/batchSame 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"
/ocrOCR 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"
| Engine | Cost | Local | Direction | Note |
|---|---|---|---|---|
auto | free | yes | any → md/docx/csv/xlsx | Picks the best engine automatically |
pandoc | free | yes | docx ↔ md; html/rtf/odt/epub → md; rtf/odt/epub → docx | Reversible round-trip (docx); HTML strips raw tags |
markitdown | free | yes | docx/xlsx/pptx/pdf/html → md | Token-efficient, one-way |
pandas | free | yes | xlsx ↔ csv; xls/ods → csv/md/xlsx | Tabular round-trip; stored values only |
pdfplumber | free | yes | pdf → md | Text-based PDFs only |
pdf_autodetect | free / $ | auto | pdf → md | pdfplumber if text, OCR if scanned |
ocr_plugin | $ | no | pdf → md | Cloud OCR via OpenRouter |
ocr_vision | $ | no | pdf → md | Page-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 mdconvert_cli.py convert file.pdf --to md --engine pdf_autodetect --jsonpython mdconvert_cli.py convert deck.pptx --to html --mode full --json