Skip to content
pdfconversionapi

PDF to TXT API

Send a PDF to POST /v2/convert/pdf/to/txt and get its text back as one UTF-8 file. We read the PDF's text layer, so you get the characters the PDF already contains, with no OCR guesses. Scanned pages have no text layer and come back empty; that case has its own route.

Endpoint
POST /v2/convert/pdf/to/txt
Accepts
pdf
Sample timing
5 ms median of 5 runsHow we measure
Request size
Up to 10 MB on the Free plan or 100 MB on paid plans, all files together

Request and response

Every sample below ran against the API before this page was published. Set PDFCONVERSIONAPI_KEY to your key and run it as is.

curl -sS -X POST \
  https://api.pdfconversionapi.com/v2/convert/pdf/to/txt \
  -H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
  -F File=@council-minutes.pdf \
  -o response.json

# FileData is base64. Save the first file in converted/,
# or print the JSON error.
if jq -e '.Files' response.json > /dev/null; then
  mkdir -p converted
  name=$(jq -r '.Files[0].FileName' response.json)
  jq -r '.Files[0].FileData' response.json \
    | base64 --decode > "converted/$name"
else
  cat response.json
fi
200 OK5 ms median1 file, 2.7 KB
{
  "ConversionCost": 1,
  "ConversionTime": 0.005,
  "Files": [
    {
      "FileName": "council-minutes.txt",
      "FileExt": "txt",
      "FileSize": 2795,
      "FileData": "CgpNYXBsZSBGYWxscyBQbGFu…"
    }
  ]
}

Response from our test run on 2026-11-03. ConversionTime shows the median of 5 runs. FileData is shortened here; the real response carries the whole file as base64.

The sample, converted

The same file the code sends. Download the input and the output and compare them yourself.

council-minutes.txt, first 30 of 79 lines

Maple Falls Planning Commission, regular meeting of October 14, 2026Minutes of the Regular MeetingCity of Maple Falls Planning CommissionCity Hall, Council Chambers, 200 Main StreetWednesday, October 14, 2026, 6:30 p.m.The City of Maple Falls, its commission and everyone named here are fictional. This sample document was written for pdfconversionapi.com and is released under CC0 1.0.1. Call to order and roll callChair Linda Ferreira called the meeting to order at 6:31 p.m.Present: Linda Ferreira (Chair), Marcus Webb (Vice Chair), Priya Raman, Tom Halvorsen, Grace Kim.Absent: Daniel Ortiz (excused). Staff: Jenna Morales, Planning Director; Alan Brooks, City Attorney; Sue Patel, Recording Secretary.Public: 23 members of the public signed in.2. Approval of minutes
Input
council-minutes.pdf (64 KB)
Output
council-minutes.txt (2.7 KB)
Source
Written for this site (fictional city); PDF saved by a word processor (CC0-1.0). How it was made
Made by
2026-11-04, API build 9eeeb0640aba

Parameters

Send these as form fields next to the file. Names are case-insensitive. If you set one of the documented options below that we don't support yet, the request fails with a 400 that names it instead of returning a file made without it.

ParameterWhat it does
PasswordstringOpens a PDF that needs a password to open. The open password is enough when the PDF allows copying text. When it forbids copying, send the owner password: it opens the file without its restrictions, while the open password keeps them and returns 422. A PDF that opens freely but forbids copying needs its owner password too; on one that allows copying, Password changes nothing.
FileNamestringName for the text file, without the extension. FileName=minutes-2026-10-14 returns minutes-2026-10-14.txt; left out, the PDF's own name is reused.
StoreFileboolean, default falseKeep the .txt on our side and return a link to it instead of the content. The link is valid for 3 hours.

Not supported yet

Setting one of these to anything but its default returns 400.

OptionWhat to do instead
PageRangeCut the pages out first with /v2/convert/pdf/to/extract and PageRange, then extract the text of that PDF. Extract refuses signed PDFs, and refuses PDFs with permission restrictions unless you send the owner password.
OcrModeThis route never runs OCR. For scans, use /v2/convert/pdf/to/ocr with OutputType=txt.
SplitPages/v2/convert/pdf/to/ocr with OutputType=txt puts a form feed between pages.

Also refused when set: OcrLanguage, RemoveHeadersFooters, RemoveFootnotes, RemoveTables, IncludeFormatting.

What carries over, and what doesn't

Kept

  • Reading order across columns: the sample's two-column attendance block came out left column first, then right, the same order pypdf 5.9 and the text output of our pdf/to/ocr route gave
  • Line breaks where the PDF wraps a line, with a blank line between paragraphs
  • Every character as UTF-8. A test line with accents, curly quotes, a euro sign, ß and Japanese came through unchanged
  • List numbers and table cell text, as plain words in reading order
  • PDFs that open without a password and restrict printing or editing but allow copying; they extract as usual

Lost or not yet supported

  • Table structure. Each row becomes one line with cells separated by single spaces, as in "Approve SP-26-07 with staff conditions 1 to 3 Webb Kim 4-1 (Halvorsen no)".
  • Page boundaries. There is no form feed or marker between pages, and running headers, footers and footnotes stay in the text on every page ("Page 1 of 2" sits between the two pages' text in the sample).
  • Footnote markers join the word before them: "along the creek.1".
  • Bold, italics and heading levels; everything is plain lines.
  • Text in images. An image-only PDF returns 200 with an empty file (0 bytes in our test).
  • Wrapped lines keep a trailing space and the file starts with two blank lines. Trim before comparing outputs.

Limits

  • Uploads up to 10 MB on the Free plan or 100 MB on paid plans; extraction stops at 120 seconds with a 504.
  • PDFs that ask for a password to open return 422 "the input file is password-protected" until you send the right Password.
  • PDFs whose permissions forbid copying text return 422 "this PDF's permissions don't allow copying its text; send the owner password in Password, or remove the restrictions with /v2/convert/pdf/to/unprotect and the owner password". Sending the owner password in Password lifts that, whether or not the file also has an open password. The open password or a wrong one keeps the 422.
  • No page selection, OCR or cleanup options on this route yet; each one returns 400 and names the option.

Where teams use it

Full-text search over uploaded PDFs

Extract the text when a file arrives and store it next to the record in Postgres, OpenSearch or whatever index you run. Users can then find a contract or a set of minutes by a phrase inside it.

Spotting scans before they reach your pipeline

An image-only PDF returns an empty file. Treat an empty or near-empty result as a signal to send the PDF to /v2/convert/pdf/to/ocr instead of indexing nothing.

Diffing two revisions of a document

Lines break where they break in the PDF, so a plain line diff between two versions of a policy or a set of minutes shows which sentences changed.

Questions

Does PDF to TXT read scanned documents?

No. This route only reads text that is already in the PDF. A scan is a picture of text, so the result is empty. Send scans to /v2/convert/pdf/to/ocr with OutputType=txt (English only). That route also leaves pages that already have text alone by default, so you can send it mixed files.

How do I get the text of one page, or of each page separately?

For a few pages, first cut them out with /v2/convert/pdf/to/extract and PageRange=2, then extract the text of the new PDF. Extract won't cut a signed PDF, nor a restricted one unless you send its owner password. For text split by page, /v2/convert/pdf/to/ocr with OutputType=txt separates pages with a form feed. On our sample it read the vote table column by column rather than row by row, so compare both outputs on your own files.

Will tables keep their columns?

No. The text of each row comes out on one line in reading order, with single spaces between cells, so you cannot tell where one cell ends and the next begins. We don't offer PDF to CSV or XLSX yet.

What encoding is the output?

Always UTF-8, without a byte order mark. We checked accented Latin letters, curly quotes, the euro sign, ß and Japanese characters; all came out as the characters the PDF showed.

Can I extract text from a password-protected PDF?

Yes, send the password in Password. In our test, a copy of the sample with an open password returned the same text with either its open or its owner password. If that PDF also forbids copying text, only the owner password works; the open password returns 422. A PDF that opens without a password but forbids copying returns 422 until you send its owner password in Password; then the text comes back as usual. Restrictions on printing or editing alone don't stop extraction.

Convert your first PDF file in a minute.