PDF Text Diff: Compare the Words
Add the old and the new PDF and click Diff the text. The text layer of each is grouped into lines, the two sequences are aligned with a longest-common-subsequence diff, and the result is shown as removed and added lines with a .diff file to download. Both files stay in your browser.
Drop exactly two PDFs here
First file = original · second = revised
Need test files? Compare sample-1-page.pdf with sample-10-pages.pdf: the body paragraphs are identical, so only the heading, the "Page N of M" line and the nine extra pages differ.
How the comparison works
- Lines: pdf.js text items are grouped by vertical position, sorted left to right and joined with spaces. On a two-column page the two columns are merged line by line. Both files get the same treatment, so the diff is still valid, but the lines read oddly.
- Alignment: a classic longest-common-subsequence table, exact while the number of lines in one file times the number in the other is at most 4,000,000. Beyond that it falls back to comparing line 1 with line 1, line 2 with line 2, and so on, where a single inserted line makes every later line look changed.
- Words: every line is split on whitespace first. That pinpoints the changed phrases in a reworded paragraph, but the 4,000,000 limit is reached at about 2,000 words per file.
- Whitespace: runs of spaces are collapsed to one space when lines are built, whichever setting is chosen, so the Whitespace control currently makes no difference to the result.
Reading the output
- On the page: only the changed entries, red lines starting
-from the first file and green lines starting+from the second, up to 400 of them. The header gives the removed and added counts. - The
.difffile, namedold-vs-new.diffafter the two inputs, starts with---and+++lines, then each change with the number of unchanged lines you asked for on either side, and@@ …where a stretch was skipped. The hunk markers carry no line numbers, so patch tools will not apply it; it is for reading and sharing. - The status line repeats the totals: "N added, M removed (lines)".
Blind spots
A text diff sees words, not appearance. A changed logo, a different font, altered spacing or a new colour is invisible to it; PDF compare diffs the rendered pixels instead. A scan has no text layer: if neither file has one the tool stops with an error, and if only one has been through OCR, its recognition errors show up as differences.
How to compare the text of two PDFs
- Drop the two PDFs, the old version first, then the new one.
- Choose the granularity: Lines for a compact view, Words when a sentence was edited and you want the exact words.
- Set the context lines (0 to 20) to include around each change in the
.difffile. - Click Diff the text and read the red and green lines.
- Download the
.diffto attach to a review or an email.
FAQ
Line or word granularity?
Start with lines. Switch to words when a paragraph was reworded and the line view shows the whole thing removed and re-added; word mode then marks only the changed words.
Why does it report differences between documents that read the same?
Line grouping. Two producers can place the same text at slightly different vertical positions, or split a superscript or a table cell into its own item, so the lines are built differently and no longer match. The percentage of such noise is usually small, and word mode reduces it further.
Can it compare a scan?
Not directly, since a scan has no text layer. Run OCR PDF on it first, and expect OCR mistakes to appear as changes.
Is there a size limit?
The exact alignment is used while lines-in-A times lines-in-B is at most 4,000,000, for example two files of 2,000 lines each. Above that the tool compares line by line by position, which still lists every difference but no longer realigns around insertions.
Related tools
- PDF visual compare: pixel differences, page by page
- PDF to Text: extract the text yourself
- PDF word count: a quick check that a text layer exists
- OCR PDF: add a text layer to a scan
- Search in PDF: find one phrase instead of everything
Part of: Review a revised document
Run both diffs. The text diff tells you what the words say now; the visual diff catches a moved logo, a changed chart or a font substitution the words cannot show.
- 1 PDF Text Diff Added and removed lines between the two versions
- 2 Compare Two PDFs Pixel differences painted over the faded original, page by page
- 3 Extract PDF Highlights Pull every highlight and comment out as Markdown, CSV or JSON
- 4 Edit PDF Metadata Check who saved it and when