PDF OCR API: scanned PDFs to Word or Markdown
Send a scanned PDF and get its text back as an editable Word document or as Markdown. The language is detected on its own.
# 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 'options={"ocr_language":"deu"}' \ -F file=@scan.pdf -F to=docx) 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 scan.docx else # 202: still running, fetch links.self. Several files: result.files. cat reply # otherwise the error fi
// npm i switchfile import Switchfile from "switchfile"; const switchfile = new Switchfile({ apiKey: process.env.SWITCHFILE_API_KEY }); const conversion = await switchfile.convert("scan.pdf", "docx", { options: { ocr_language: "deu" }, }); if (conversion.result.incomplete) console.log((conversion.result.notes ?? []).join("\n")); else await switchfile.download(conversion, "scan.docx");
# pip install switchfile-sdk import os import switchfile switchfile.configure(api_key=os.environ["SWITCHFILE_API_KEY"]) conversion = switchfile.convert("scan.pdf", "docx", {"ocr_language": "deu"}) if conversion["result"]["incomplete"]: print("\n".join(conversion["result"].get("notes", []))) else: switchfile.download(conversion, "scan.docx")
<?php // composer require switchfile/switchfile-php require "vendor/autoload.php"; $switchfile = new Switchfile\Switchfile(["api_key" => getenv("SWITCHFILE_API_KEY")]); $conversion = $switchfile->convert("scan.pdf", "docx", ["ocr_language" => "deu"]); if ($conversion["result"]["incomplete"]) echo implode("\n", $conversion["result"]["notes"] ?? []), PHP_EOL; else $switchfile->download($conversion, "scan.docx");
What comes back
With Accept: application/octet-stream, as in the curl example, a 200 response is the file itself when the conversion has exactly one result file. With several result files, for example one image per page, or without that header, you get the conversion as JSON, and the files are in result.files:
{
"id": "0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10",
"object": "conversion",
"status": "finished",
"progress": 100,
"input": {
"filename": "scan.pdf",
"format": "pdf",
"size": 48213
},
"to": "docx",
"options": {
"ocr_language": "deu"
},
"result": {
"files": [
{
"filename": "scan.docx",
"size": 61544,
"url": "https://api.switchfile.io/files/2a6f8e1c-4b3d-4e7a-9c5f-8d1b0e2a4c67/scan.docx?expires=1794074402&signature=3f9c2a7d41e8b6c05d1f9e2a7b4c8d3e6f0a1b2c3d4e5f60718293a4b5c6d7e8"
}
],
"incomplete": false
},
"download_url": "https://api.switchfile.io/files/2a6f8e1c-4b3d-4e7a-9c5f-8d1b0e2a4c67/scan.docx?expires=1794074402&signature=3f9c2a7d41e8b6c05d1f9e2a7b4c8d3e6f0a1b2c3d4e5f60718293a4b5c6d7e8",
"error": null,
"credits": 2,
"batch_id": null,
"created_at": "2026-11-06T18:00:00+00:00",
"finished_at": "2026-11-06T18:00:02+00:00",
"expires_at": "2026-11-07T18:00:02+00:00",
"links": {
"self": "https://api.switchfile.io/v1/conversions/0b8a7c1e-5d0f-4a51-9f39-2f7f4c1d9a10"
}
}What you get
Language on its own
Editable Word file
Markdown for language models
On by default
Options
Send them in options as JSON. Options that do not fit the format are rejected with a message that names them.
| Option | Meaning |
|---|---|
| ocr_ | Language of scanned pages: "auto" (detected on the first scanned page) or "deu", "eng", "spa", "fra", joined with + as in "deu+eng". Default: auto. |
| images_ | Read text from scanned pages. Default: true. |
| pagespages | Pages to convert, for example 1-3,5 or all. Up to 50 pages without credits, up to 300 with credits. |
Where your files go
Converted on our server
Without storage: store=false
Data processing agreement
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=@scan.pdf -F to=docx)
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 scan.docx
else
cat reply # otherwise the error
fiPricing
Free
20
up to 50 pages per conversion, free API key
Credit pack
ā¬7
500 credits, one-time, no subscription
Monthly
ā¬4
500 credits a month, cancel at any time
PDF to Word: 1 credit per started minute of conversion time, at least 2 per file.
PDF to Markdown: 1 credit per started minute of conversion time, at least 1 per file.
Up to 300 pages with credits.
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
See all pricesSDKs and integrations
Questions
About OCR through the API.
What are the limits?
Without credits a PDF can have up to 50 pages, with credits up to 300. For txt the limit counts only scanned pages, so up to 50 scanned pages without credits; with more scanned pages the conversion fails with a message, but only when text recognition is on (images_ocr). Within that limit, or with images_ocr set to false, pages that already contain text are all read without pages or with pages=all; a page list such as pages=1-300 can name up to 300 pages. For a longer PDF, convert it in parts with the pages option. Files can be up to 1 GB. A file sent in the request can be up to 100 MB; larger files go through an upload, which the SDKs do on their own. One conversion can run for up to 5 minutes. Without storage (store=false), files can be up to 50 MB.
Which languages are recognized?
German, English, Spanish and French, each with its code (deu, eng, spa, fra). Several languages are joined with a plus sign, for example "deu+eng". Without ocr_language the language is detected on the first scanned page.
Can I send a photo or an image file?
Not yet. Text recognition runs on PDFs. Images such as JPG or PNG are not read.
Can I get plain text?
Yes. Convert to txt; scanned pages are read with text recognition. Without credits up to 50 scanned pages are read per PDF.
How long do you keep my files?
A stored conversion keeps the file and the result for 24 hours, then both are deleted. With store=false no file is stored: the result comes back in the response, and only an entry with time, formats, sizes and credits stays in your usage history for 400 days.