PDFs Are Programs in a Trench Coat
Most people meet PDFs as the safest-looking files in computing: documents, not programs. The format's specification disagrees. A PDF can run JavaScript when it opens. It can carry entire files inside itself. Its annotations can hold actions, attachments and links. Its forms can compute and submit. Every one of those capabilities exists for good reasons — and every one has been abused, because a file that arrives “just a document” gets opened with a trust programs never receive.
Sanitizing is the practice of demoting a PDF back to a document: keep the pages, remove the machinery. This tool does it structurally, in your browser, and counts what it finds — because “we removed 1 script, 2 attachments and 14 annotations” is information, while “your file is now safe” would be a claim nobody can honestly make.
What Gets Removed, Item by Item
| Removed | Where it lives | Why it's a risk |
|---|---|---|
| Open / additional actions | Catalog /OpenAction and /AA | Code that fires the moment the file opens |
| Named JavaScript | Names dictionary → JavaScript name tree | Scripts callable by actions and events |
| Embedded files | Names dictionary → EmbeddedFiles name tree | Whole files — including executables — hidden in a “document” |
| Annotations | Each page's /Annots array | Pop-ups, links, file-attachment markers, form widgets — interactive objects with their own actions |
| Metadata | Info dictionary + catalog /Metadata (XMP) | Names, tools and internal labels leak with the file |
The removal is structural: entries are deleted from the document's dictionaries and the file is saved fresh, so the removed material isn't hidden or disabled — it's absent. The counts come from the file itself as it's cleaned: name-tree entries, annotation array sizes, metadata fields that were actually present.
How to Sanitize a File, Step by Step
The counts are the step people skip, and they're the point. Zero across the board on a file from a trusted source is a shrug. Three attachments and a script in an “invoice” from a stranger is a story — one you may want to tell whoever sent it, or your IT department, before anyone opens the original. Because the original is untouched, sanitizing is also safe triage: clean first, examine the copy, escalate the original if the counts warrant it.
Under the result sits a share row. Copy Results puts a short text summary (the headline counts) on your clipboard; Share Link passes this page on; Email Results opens your mail app with the summary already written. Reset clears the file and the result, and it asks for confirmation first.
Why This Is Not an Antivirus — and What Is
An antivirus examines content: it pattern-matches byte sequences against known malware and analyses behaviour. Sanitizing examines structure: it removes the places active content legitimately lives. The two overlap — most commodity PDF malware uses exactly the script and attachment routes removed here — but they are not the same discipline, and the gap matters:
- A maliciously crafted content stream exploiting a reader bug is not removed by structural cleaning.
- A booby-trapped embedded font or image is content, not structure.
- A perfectly clean structure can still wrap a document whose text is a phishing lure — no tool fixes persuasion.
The honest stack is layered: sanitize files from untrusted sources, open them in a current reader (reader updates close the exploit class), let your antivirus scan downloads as usual, and stay suspicious of urgency in any document. Sanitizing is the cheapest, fastest layer — not the only one.
Side Effects: Forms, Links and Signatures
These are consequences to choose, not surprises to suffer. Distributing a filled form? Sanitize the outgoing copy and keep the fillable original. Publishing a document whose links matter? Links drawn as annotations will be removed — check the sanitized copy before it goes out. Signed document? Sanitizing invalidates verification, like every edit; sanitize before signing, never after. The tool's job is to make the safe copy; deciding which copy is the safe one stays with you.
Common Problems and How to Fix Them
Sanitizing is one click; its problems are about copies and expectations:
- The form stopped working. Expected — fields were annotations and were removed. Use the original for filling; sanitize only the distribution copy.
- Attachments I wanted are gone. Also by design. Extract them from the original first (your reader's attachments panel), then sanitize.
- All counts are zero but I still don't trust the file. Correct instinct — read the antivirus section. Sanitizing is one layer; a zero count is not a certificate.
- The upload failed. The file is likely password-protected or damaged — and a suspicious file you cannot open or clean should be deleted or escalated, not wrestled with.
- The sanitized file still shows an author in our system. Your system may stamp or read copies differently — confirm you're looking at the -sanitized.pdf file's own Properties.
What This Tool Cannot Do
It cannot certify a file safe, scan content streams for exploits, or detect malicious intent in ordinary-looking content — it is not an antivirus. It cannot sanitize a file it cannot open (password-protected files need unlocking first, if you know the password). It cannot preserve form fillability, annotation links or signature validity — removing interactive objects is the treatment, and those are interactive objects. What it can do, it does completely: the documented active-content structures are deleted, counted and reported, in your browser, with the original preserved.
Your Files Never Leave Your Device
A suspicious file is the last thing to upload to a stranger's server — you'd be spreading the very thing you're trying to contain, and logging your documents in the process. This tool works the other way: the PDF library (pdf-lib) runs as a script inside your browser tab, your file is read from your device, and the sanitized PDF is assembled there too. Nothing is uploaded, nothing is stored, and there is no account holding a history of your documents. Close the tab and everything is gone — which also means you should save the sanitized file before you close it.
Sources & References
- pdf-lib — the open-source library this page loads (version 1.17.1) used to delete the actions, name trees, annotations and metadata in your browser.
- Wikipedia — ISO 32000 — the PDF standard: actions, name trees, annotations and embedded files as the format defines them.
- CISA — Avoiding Social Engineering and Phishing Attacks — the US cybersecurity agency's guidance on malicious attachments and the habits that defeat them.
- Wikipedia — PDF — the Portable Document Format itself: history, structure, JavaScript and security notes.
- MDN Web Docs — FileReader — the browser API this page uses to read your file locally, on your device.
Sources checked November 2026.