PDF to text

Open a PDF and download its text as a .txt file. The page reads the text that is stored in the PDF, so a PDF made from a document comes out exact, while a scan is refused with a plain message because there is no OCR. Your browser does the reading and nothing is uploaded.

PDF to text

How to turn a PDF into a text file

  1. Drop up to 20 PDFs on the panel or click it to choose files.
  2. Type a range such as 2-3 in Pages (empty = all pages), or leave it empty to read every page.
  3. Tick Mark each page if you want a line such as --- Page 3 --- before the text of each page.
  4. Click Extract text. Each PDF gets one .txt, and a note gives its page and character counts.
  5. Download each file, or use the ZIP button when you converted several PDFs.

What the tool reads and writes

A PDF can hold text as real characters or as a picture of text. This page reads only the first kind. pdf.js, the PDF reader built into Firefox, pulls the stored characters out of each page and the page saves them as one UTF-8 .txt file per PDF.

We compared it with pdftotext, the command-line reader from the Poppler tools. Our 5,696-byte, 5-page sample gave 5,604 characters and 1,025 words, and pdftotext counted the same 1,025 words and 4,575 characters without spaces. Each run took about half a second.

The reading happens in your browser tab, and pdf.js comes from jsDelivr, hash-checked. In our test the page made 13 requests: two to Google ad and analytics servers and 2 to jsDelivr for pdf.js, and none had a body. Only Chromium was tested.

Scanned PDFs: what happens and how to tell

A scan is a photo of paper inside a PDF, so there are no characters to extract. Our 3-page, 1.3 MB scanned sample was refused with this message: this PDF has no text to extract. It is probably a scan or a PDF made from pictures, and this tool does not read pictures (no OCR). No file was made.

You can check first: open the PDF in any viewer and try to select a word. If nothing highlights, the page is a picture. Turning a picture into text is called OCR, and this page does not do it.

A PDF does not have to be a scan to disappoint you. Our 2.7 MB photo-heavy sample has three pages and almost no characters on them. It was not refused: it produced 41 characters and 9 words, the same 9 pdftotext found, and the note said 30 characters without spaces across 3 pages. A count that low next to a large file means the content is in the pictures.

Page range, page markers and several files

The box labelled Pages (empty = all pages) accepts values such as 2 or 2-3. On the 5-page sample, page 2 alone gave 1,135 characters and 209 words, and pages 2 to 3 gave 2,241 characters and 410 words. Asking for page 9 of the 5-page file gave a message that it is beyond the last page, and no file.

Mark each page puts a line such as --- Page 3 --- before that page. On the 5-page sample it added 75 characters and 20 words, which is five markers of four words each.

Up to 20 PDFs can be added at once. Three of our samples together took 1.1 seconds and gave three .txt files, and the ZIP button saved a 779-byte archive that unzip reported as free of errors.

Chinese, Japanese, Arabic, Thai and Hindi

We made a test PDF with Chromium, with one line each in six scripts, and ran it through the page. English, Chinese and Japanese came back exactly. Arabic kept 97.0% of its letters in order, with two adjacent letters swapped. Thai kept 97.6%, with one tone mark missing. Hindi kept 92.3%: in पार्क the reph was lost and the word came back as पाक.

The page warned that some characters looked unreadable, because the PDF's fonts do not say which letters they draw. The limit is in the PDF, not the browser. We tested one PDF from one program, so treat the percentages as an example and read the result yourself for any script other than English, Chinese and Japanese.

What gets lost

The output is plain text: no fonts, pictures or bold, and line breaks follow what pdf.js reports. We did not test multi-column pages or tables, so check those by eye. On your own computer, pdftotext has a -layout option for columns.

Errors and limits

A password-protected PDF is refused with password protected, remove the password first, and a text file renamed to .pdf is refused with this is not a valid PDF file.

The code allows 20 files per run, 200 MB per file and 2,000 pages per run. We did not run files that large. Extract PDF pages can cut a bigger PDF down first.

Related conversions

To make a PDF from a text file, use Text to PDF. When you need each page as a picture instead of its text, PDF to JPG draws the pages.

Measured results

Runs of the page in headless Chromium with pdf.js. The text was read back from the download links and compared with pdftotext.
InputSettingWhat came out
text-5-pages.pdf, 5 pagesDefaults5,604 characters, 1,025 words; pdftotext finds the same 1,025 words
text-5-pages.pdfMark each page5,679 characters, 1,045 words, five "--- Page n ---" lines
photo-heavy-3-pages.pdf, 2.7 MBDefaults41 characters, 9 words; not refused
scanned-3-pages.pdf, 1.3 MBDefaultsRefused, no file, message names the missing OCR
Three PDFs togetherZIPThree .txt files in 1.1 s; 779-byte ZIP, no errors
Six-script PDF from ChromiumDefaultsEnglish, Chinese, Japanese exact; Arabic 97.0%, Thai 97.6%, Hindi 92.3% of letters in order

Prefer desktop software?

A desktop PDF editor is the better route for a scan that needs OCR, or when layout must survive. We list Foxit PDF Editor and Nitro PDF Pro; check each one's feature list for OCR before you choose.

Frequently asked questions

Is my PDF uploaded?

No. Your browser opens the PDF and reads the text on your device. In our logs no request had a body and none held the file.

Can it read a scanned PDF?

No. A scan has no stored text and the page does not do OCR, so it refuses the file with a message that says so. To check a PDF yourself, try to select a word in a viewer.

Does it keep the layout?

No. You get plain text with line breaks. We did not test columns or tables, so check them in the result.

Why are some Arabic, Thai or Hindi letters wrong?

Some PDF fonts do not record which letters they draw. In our test PDF, Arabic kept 97.0% of its letters in order, Thai 97.6% and Hindi 92.3%, and the page warns you.

How large a PDF can I use?

The code allows 200 MB per file, 2,000 pages per run and 20 files. We did not run files that large.