# PDF to Markdown API for LLM and RAG pipelines

> Convert PDFs to Markdown for RAG and LLM pipelines through an API. Tables become pipe tables, scans are read too. Free API key, 20 files a day.

Send a PDF and get Markdown back that a language model can read. Tables become pipe tables, and the text follows the reading order of the page.

switchfile converts PDF to Excel, Word, PowerPoint and Markdown with its own engine, which we built ourselves. We measured PDF to Office against other online converters on 346 public PDFs we had never used. [PDF to Office benchmark](https://switchfile.io/benchmarks/pdf-to-office)

```bash
# API key: switchfile.io/dashboard/keys
code=$(curl -sL "https://api.switchfile.io/v1/convert?wait=30" \
  -o reply -D headers -w "%{http_code}" \
  -H "Authorization: Bearer $SWITCHFILE_API_KEY" \
  -H "Accept: application/octet-stream" \
  -F file=@report.pdf -F to=md)
if grep -qi '^x-incomplete' headers; then
  grep -i '^x-notes' headers  # partial result, left in reply
elif [ "$code" = 200 ] && grep -qi '^content-disposition' headers; then
  mv reply report.md
else
  # 202: still running, fetch links.self. Several files: result.files.
  cat reply  # otherwise the error
fi
```

```js
// npm i switchfile
import Switchfile from "switchfile";

const switchfile = new Switchfile({ apiKey: process.env.SWITCHFILE_API_KEY });
const conversion = await switchfile.convert("report.pdf", "md");
if (conversion.result.incomplete) console.log((conversion.result.notes ?? []).join("\n"));
else await switchfile.download(conversion, "report.md");
```

```python
# pip install switchfile-sdk
import os
import switchfile
switchfile.configure(api_key=os.environ["SWITCHFILE_API_KEY"])
conversion = switchfile.convert("report.pdf", "md")
if conversion["result"]["incomplete"]:
    print("\n".join(conversion["result"].get("notes", [])))
else:
    switchfile.download(conversion, "report.md")
```

[Get a free API key](https://switchfile.io/signup) (20 files a day). [Try it in the browser](https://switchfile.io/pdf-to-md).

## What comes out

- **Tables as pipe tables**: Each table becomes a Markdown table with a header row and one cell per value, so a model can tell which number belongs to which line item.
- **Text in reading order**: Headings and lists keep their structure. Running headers and page numbers are left out, so they do not end up in the middle of a paragraph or a chunk.
- **Scanned pages too**: Scanned pages are read with text recognition. The language is detected on its own, or you set it with ocr_language, for example deu for German.
- **Page numbers for citations**: Each page starts with an HTML comment such as <!-- page 4 -->, so a chunk can point back to its page. Pictures appear as placeholders without image data.

```markdown
<!-- page 4 -->
## Revenue by region

| Region | Q1 | Q2 |
| --- | --- | --- |
| North | 1,234.56 | 1,310.00 |
| South | 789.00 | 802.40 |
```

- [Word to Markdown](https://switchfile.io/docx-to-md): Headings and tables keep their structure. Images are left out; alt text stays as [Image: alt text].
- [PowerPoint to Markdown](https://switchfile.io/pptx-to-md): Each slide becomes a section with its title and text, followed by its speaker notes.
- [Excel to Markdown](https://switchfile.io/xlsx-to-md): Each worksheet becomes a section with one table, with values formatted the way the spreadsheet shows them.

## Tables in a public benchmark

In our public benchmark of 160 business PDFs, switchfile put 93.8 % of the numbers in the right table cell, the highest-scoring open-source tool selected for this comparison 67.9 %, as a mean per PDF with numeric table cells (n = 102 of 160). One more open-source tool in the benchmark repository scored higher than the selected open-source tools and is left out of this comparison. Measured by us on 16 November 2026, digital PDFs only. [See the benchmark](https://switchfile.io/benchmarks/pdf-to-markdown)

## Long documents: start now, collect later

```bash
# Answers 202 right away with the conversion id and links.self.
# When it is done, conversion.finished is sent to your webhook_url.
curl "https://api.switchfile.io/v1/convert" \
  -H "Authorization: Bearer $SWITCHFILE_API_KEY" \
  -F file=@handbook.pdf -F to=md \
  -F webhook_url=https://example.com/hooks/switchfile
```

```js
// Returns right away with status queued; wait later or handle the webhook.
const queued = await switchfile.convert("handbook.pdf", "md", {
  wait: false, webhookUrl: "https://example.com/hooks/switchfile",
});
const done = await switchfile.conversions.wait(queued.id);
await switchfile.download(done, "handbook.md");
```

```python
# Returns right away with status queued; wait later or handle the webhook.
queued = switchfile.convert("handbook.pdf", "md", wait=False,
                            webhook_url="https://example.com/hooks/switchfile")
done = switchfile.Conversion.wait(queued["id"])
switchfile.download(done, "handbook.md")
print(done["credits"], "credits")
```

## Where your files go

- **Converted on our server**: Conversions run on our server in the EU. Stored files and results are deleted after 24 hours. [Hosting in the privacy policy](https://switchfile.io/privacy#hosting)
- **Without storage: store=false**: The PDF and the Markdown are processed in memory while the request runs and are not written to our file storage or database. The service that converts them cannot open connections to the internet. Files can be up to 50 MB. Your usage history keeps the time, formats, sizes and credits, never the file name. [Converting without storage](https://switchfile.io/docs/no-store)
- **Data processing agreement**: We sign a data processing agreement (DPA) under Art. 28 GDPR on request. Write to hello@switchfile.io. [Security](https://switchfile.io/security#dpa)

```bash
code=$(curl -s "https://api.switchfile.io/v1/convert?store=false" \
  -o reply -D headers -w "%{http_code}" \
  -H "Authorization: Bearer $SWITCHFILE_API_KEY" \
  -F file=@contract.pdf -F to=md)
if grep -qi '^x-incomplete' headers; then
  grep -i '^x-notes' headers  # partial result, left in reply
elif [ "$code" = 200 ] && grep -qi '^content-disposition' headers; then
  mv reply contract.md
else
  cat reply  # otherwise the error
fi
```

## Pricing

Free: 20 files/day, up to 50 pages per conversion, free API key
Credit pack: from €7, 500 credits, one-time, no subscription
Monthly: from €4, 500 credits a month, cancel at any time
PDF to Markdown is billed by conversion time, not by page: 1 credit per started minute, at least 1 per file. Up to 300 pages with credits.
A file that is done within a minute uses 1 credit, which costs €0.0043 to €0.014 depending on the plan or pack.
Add ?dry_run=1 to a convert request to see the credits and the price of a file before you convert it. [Cost before converting](https://switchfile.io/docs/simple-api#dry-run)
[Pricing](https://switchfile.io/pricing)

## SDKs

Client libraries and integrations: [SDK overview](https://switchfile.io/developers#sdks).

## Questions

### What does the Markdown file contain?

Headings and lists keep their structure, and tables become Markdown tables. Running headers and page numbers are left out. Each page starts with an HTML comment that gives its number. Pictures appear as placeholders without image data, and footnotes stay on their page.

### Does it work with scanned PDFs?

Yes. Scanned pages are read with text recognition, so their text ends up in the Markdown too. The language is detected on its own; to set it, pass ocr_language, for example deu for German.

### Can I send Office files too?

Yes, with the same call and to=md. A Word file keeps its headings and tables. A presentation becomes one section per slide with the speaker notes, and a workbook one section per worksheet with its table.

### What are the limits?

Without credits you get 20 files and 20 minutes of conversion time a day, whichever runs out first, and a PDF can have up to 50 pages and 1 GB. With credits a PDF can have up to 300 pages. For a longer PDF, convert it in parts with the pages option, for example 1-50. Without storage, a file can be up to 50 MB.

### How long do you keep my files?

A stored conversion keeps the PDF and the Markdown for 24 hours, then both are deleted. With store=false no file is stored: the Markdown comes back in the response, and only an entry with time, formats, sizes and credits stays in your usage history for 400 days.
