A lightweight open-source tool for detecting textual differences between PDFs
Comparing two versions of a PDF should not necessarily require uploading documents to an online service.
This is especially true when working with internal documentation, reports, invoices, technical files, or documents that simply should not leave your machine.
I built PDF Comparator, a small open-source Python tool designed for exactly that purpose.
It compares the textual content of two PDF files locally and shows what changed between them.
No AI, no external API, no account, and no document upload.
How it works
The principle is intentionally simple:
- PDF A → Text extraction
- PDF B → Text extraction → Lightweight normalization → Comparison → Differences
The first PDF is considered the reference version, while the second is the new version.
The tool extracts text from all pages, performs lightweight normalization, then detects added and removed lines.
For example:
--- old.pdf
+++ new.pdf
-Address: 12 Example Street
+Address: 24 Example Street
-Total: €1,200
+Total: €1,350
Instead of manually checking two documents line by line, the differences are immediately visible in the terminal.
Running it
The project only requires Python 3 and pypdf.
Clone the repository and install the dependency:
git clone https://github.com/Palks-Studio/pdf-comparator
cd pdf-comparator
python -m pip install -r requirements.txt
Then compare two PDFs:
python pdf-compare.py old.pdf new.pdf
If no textual difference is found, the tool simply reports that no difference was detected.
Otherwise, the differences are displayed directly in the terminal.
Local by design
One of the main reasons I built this tool was to keep the workflow simple and local.
The PDFs are processed directly on your machine.
There is:
- no file upload
- no remote server
- no external API
- no AI processing
For documents containing internal or sensitive information, avoiding an unnecessary external transfer can be just as important as the comparison itself.
What it can be useful for
PDF Comparator can help when reviewing different versions of:
- technical documentation
- reports
- invoices
- specifications
- administrative documents
- generated PDFs
- archived documents
It can also be useful during development when a system generates PDFs and you want a quick way to check whether textual content changed between two outputs.
What it does not do
PDF Comparator is deliberately focused on textual differences.
It does not compare:
- images
- fonts
- colors
- graphical layout
- visual rendering
It also does not interpret the meaning of a change.
If a value changes from 1200 to 1350, the tool detects the difference, but it does not try to determine whether that change is correct.
The quality of the comparison also depends on the text layer available inside the PDF. A scanned document containing only images cannot be reliably compared without OCR.
Keeping this distinction explicit makes the tool predictable: it does one job and stays focused on it.
Open source
PDF Comparator is available as an open-source project under the MIT License.
The repository contains the Python script, requirements, documentation in English and French, and installation instructions.
Repository
Contributions, feedback, issues and improvements are welcome.
Sometimes a useful tool does not need a platform, an account, or another service in the middle.
Two files, one local script, and the differences.

Top comments (0)