---
title: "PDF to Markdown API for RAG · document conversion in the EU"
description: "Convert PDF, Word, PowerPoint and Excel files to clean Markdown for RAG and LLM prompts. Tables, headings and scanned pages, processed in the EU."
canonical: "https://inference.eu/api/document-conversion/"
language: "en"
---

POST /v1/documents/convert

# Document conversion API: PDF and Office files to Markdown, in the EU

Most company knowledge lives in PDFs, Word documents, slide decks and spreadsheets, and language models work best with clean text. The document conversion endpoint turns those files into Markdown that keeps headings, lists and tables, ready to chunk for search or to paste into a prompt. Contracts and internal reports are often the most sensitive files you have, and they are converted in European data centres.

[Contact sales](https://inference.eu/contact/)[Example request](#example)

1.  01API format: OpenAI
2.  02EU data centres
3.  03Covered by one DPA

POST /v1/documents/convert

```
curl https://api.inference.eu/v1/documents/convert \
  -H "Authorization: Bearer $INFERENCE_EU_API_KEY" \
  -F file="@rahmenvertrag-2026.pdf" \
  -F output_format="markdown" \
  -F ocr="auto"

# {
#   "object": "document",
#   "filename": "rahmenvertrag-2026.pdf",
#   "pages": 14,
#   "output_format": "markdown",
#   "content": "# Rahmenvertrag\n\n## § 1 Vertragsgegenstand\n\n..."
# }
```

## What the endpoint does

`POST /v1/documents/convert` takes a file as `multipart/form-data` and returns its content as text. Send the file in `file` and choose `output_format`: `markdown` keeps structure such as headings, numbered clauses, lists and tables, while `text` returns plain text without markup. The response contains the `filename`, the number of `pages` and the converted `content`.

Supported inputs include PDF, Word (`.docx`), PowerPoint (`.pptx`), Excel (`.xlsx`), HTML and common image formats. Born-digital PDFs are read directly, which is fast and exact. Scanned pages and photos of documents go through optical character recognition.

## Key request fields

`ocr` controls text recognition. `auto`, the default, detects pages without a text layer and recognises them, while keeping digital text as it is. `force` runs recognition on every page, which helps with PDFs whose embedded text is broken or garbled. `off` skips it, which is fastest when you know the files are digital.

Tables are converted to Markdown tables so that rows and columns stay aligned for the model. Headers, footers and page numbers that repeat on every page are removed where they can be detected, because they add noise to retrieval. Spreadsheets become one table per sheet, and slides become one section per slide with the slide title as heading.

## A practical pattern for RAG

A retrieval pipeline starts here. Convert each document to Markdown, then split it along its headings rather than at a fixed number of characters, so each chunk is a coherent section: a contract clause, a policy paragraph, a slide. Keep the heading path and the page number with each chunk as metadata, so answers can cite the source.

Embed the chunks with an embedding model, store them in your vector database, and rerank results at query time. For extraction tasks, send the Markdown to a chat model with a JSON schema instead. Converting once and storing the Markdown is cheaper than converting the same file on every question.

## Errors and edge cases

Password-protected or encrypted files cannot be read and return a 400 error; remove the protection first. Corrupted files and unsupported formats also return 400 with a message naming the problem. Files above the maximum size return 413; the limit depends on your plan, and we confirm it with you.

Very complex layouts, such as multi-column newsletters, nested tables or text inside diagrams, can come out in an unexpected order. Check a sample of converted files from each source before indexing everything. Handwriting and poor scans reduce recognition quality; for pages where charts or handwriting carry the meaning, send the page image to a vision model as well.

## Document conversion

Endpoint

POST /v1/documents/convert

Category

Tools

API format

OpenAI

Base URL

api.inference.eu/v1

Processing

EU data centres

Training on your data

Never

## Document conversion: common questions

The questions buyers, developers and legal teams ask us most. Something missing? Ask us directly.

Upload the PDF to \`POST /v1/documents/convert\` with \`output\_format\` set to \`markdown\`. The response contains the document as Markdown, with headings, lists and tables preserved. Split it along headings into chunks for embeddings, or put it straight into a prompt if it fits the model's context window.

PDF, Word (\`.docx\`), PowerPoint (\`.pptx\`), Excel (\`.xlsx\`), HTML and common image formats such as PNG and JPEG. Older binary Office formats like \`.doc\` work best if you save them as the current format first. Tell us if you need another format for a large archive.

Yes. With \`ocr\` set to \`auto\`, pages without a text layer are run through optical character recognition, and digital pages are read directly. Use \`force\` if a PDF has an embedded text layer that is broken. Recognition quality depends on scan resolution and print quality.

Yes. Tables are converted to Markdown tables, so rows and columns stay aligned and a model can read them. Merged cells and nested tables are simplified. For spreadsheets, each sheet becomes its own table, with the sheet name as a heading.

Markdown keeps the structure that gives text its meaning: which line is a heading, which items belong to a list, which numbers sit in which column. That helps you split documents into coherent chunks and helps models answer accurately. Plain text loses that structure but is fine for simple full-text search.

No. Files are processed in EU data centres to produce the converted text, which is returned in the response, and are not kept afterwards or used to train models. Store the Markdown in your own systems if you need it again.

The maximum file size and page count per request depend on your plan, and we confirm them with you. For very large documents, split the file into parts before conversion. For archives with thousands of files, run conversions from a queue with retries.

Yes. Digital text in any language is read as it is, including umlauts, accents and other special characters. Text recognition for scanned pages supports all major European languages. Check a few scanned samples per language before you convert a large archive.

[Ask a question](https://inference.eu/contact/)

## Related

[API overview](https://inference.eu/api/)

-   [EmbeddingsTurn text into vectors for search, RAG and clustering with an OpenAI-compatible embeddings API. Open embedding models, processed in EU data centres.Endpoints](https://inference.eu/api/embeddings/)
-   [RerankRe-order search results by relevance with a rerank API for RAG. Cross-encoder reranker models such as bge-reranker-v2-m3, processed in EU data centres.Endpoints](https://inference.eu/api/rerank/)
-   [Structured outputsGet valid JSON that matches your schema from open models with OpenAI-compatible structured outputs. JSON mode, json\_schema, strict mode and pitfalls.Guides](https://inference.eu/api/structured-outputs/)
-   [VisionSend images to open vision models with the OpenAI chat format. Read receipts, screenshots, forms and photos, with requests processed in EU data centres.Guides](https://inference.eu/api/vision/)

## Move your AI workloads to EU infrastructure

Tell us which models you use and roughly how much traffic you have. We reply within one working day with pricing and next steps.

-   Reply within one working day
-   Pricing for your volume
-   DPA ready to sign
