PDF to Text & Markdown
runs in your browserRead the text out of a PDF in your browser as Markdown or plain text: headings from type size, lists, joined paragraphs, no running headers.
Drop a file here, or .
One PDF. The text is read in your browser; nothing is uploaded.
about this tool
From glyphs to prose
A PDF does not contain paragraphs. It contains glyphs at coordinates, so every part of getting readable text back is a heuristic — and each one here is a pure function with its own tests.
Runs of text on the same baseline become a line, with a space inserted where the horizontal gap is wider than a fifth of the type size. Lines become paragraphs: a line that reaches the right-hand edge is assumed to have wrapped, so the next line joins it, while a short line ends the paragraph. The leading is taken from the gap that occurs most often on the page, so an unusually large gap starts something new. A word broken across a line ending in a hyphen is put back together when the next line starts in lower case.
Headings, lists and furniture
The type size most of the document's characters are set in counts as body
text. A line 15 percent larger becomes a third-level heading, 30 percent a
second, 60 percent a first. Lines starting with a bullet character or a
marker such as 2., b) or (3) become list items, and their
continuation lines are folded in. Both are measured over the whole
document, so picking a single page out of a report does not change what
counts as a heading.
Running headers and footers are found by looking at the top and bottom
twelfth of every page and normalising digits, so Page 3 of 20 and
Page 4 of 20 count as the same line. Anything appearing on at least 60
percent of the pages, in a document of at least three, is left out. The
panel says how many lines that removed.
Markdown that survives a round trip
In Markdown mode the text is escaped: backslashes, asterisks, underscores,
backticks, brackets and angle brackets inline, and a leading #, >,
- or 1. on a body line, so a sentence that happens to start with a
dash does not silently become a list. Plain text mode writes the lines as
they are, with first-level headings in capitals. Page breaks can be left
out, marked with a rule, or labelled with the page number; paragraphs are
joined across a page break only when no separator is shown, since the two
requests contradict each other.
Limits
Two-column layouts, tables, footnotes and sidebars come out in reading order by baseline, which is not their reading order — a table becomes a run of cells. Vertical and right-to-left text is not reordered. Bold and italic are not detected, because pdf.js reports a generic font family rather than the real font name, so no emphasis is written. Pages that hold no text are listed as probably scanned; the OCR tool reads those. Everything runs in your browser and nothing is stored between visits.
If the PDF is a scan with no text layer, this will find nothing — image to text (OCR) is the tool for that. The Markdown output pastes straight into the Markdown editor for a preview.
questions
- How does it know what is a heading?
- By type size. The size most of the document’s characters are set in counts as body text, and a line at least 15 percent larger becomes a heading — 60 percent larger is a level one, 30 percent a level two. It is a guess, and you can switch it off.
- Why is my text one word per line, or full of odd spaces?
- A PDF stores glyphs at coordinates, not sentences, so runs have to be grouped by baseline and spaces inferred from the gaps. Unusual typesetting, two columns or tables can defeat that. Turning off “join wrapped lines” gives you the raw lines to fix by hand.
- Nothing came out. What now?
- The pages are images: a scan or a photographed document holds no text at all. The OCR tool reads text out of images and will get you something to work with.
- What are running headers and footers?
- Lines that repeat at the top or bottom of most pages, such as a document title or “Page 4 of 20”. They are matched with digits treated as interchangeable, so every variation of a page footer counts as the same line, and dropped when they appear on at least 60 percent of at least three pages.
- Is the file uploaded?
- No. pdf.js reads the text in your browser and everything after that is arithmetic on this page. Nothing leaves the page and nothing is stored between visits.