How to Unlock a PDF
Unlocking a PDF only works when you know the password — or when the file has no open password at all, only printing and copying restrictions. No legitimate tool recovers a password you have forgotten. If you do know it, removing it takes one command. Here is the exact flow, tested.
At a glance
- qpdf --decrypt removes the password from a PDF you own, in one command.
- A wrong password fails loudly — qpdf exits with code 2 and says invalid password.
- Tested 6 November 2026: a locked 3-page PDF (2,638 bytes) became an unlocked 2,163-byte file that opens without a password.
- A pypdf script does the same job when qpdf is not installed.
- Only unlock files you own or have the right to unlock. PDF Probe does not unlock PDFs.
Steps
- Install qpdf (free, open source): on Linux
sudo apt install qpdf; on macOSbrew install qpdf. The test used qpdf 11.9.0. - Check the file:
qpdf --check locked.pdfreports the encryption. On the test file, pypdf also reported the file as encrypted and refused to read text without the password. - Unlock it:
qpdf --decrypt --password=test123 locked.pdf unlocked.pdf— the unlocked file is written separately, the original is untouched. - Verify: open unlocked.pdf — no password prompt — and check the pages. On the test file, all 3 pages were there and the file shrank from 2,638 to 2,163 bytes.
- No qpdf? A short pypdf script does the same (see the section below): open with the password, write the pages out unencrypted.
Worked example (tested 6 November 2026)
I tested this with a 3-page PDF encrypted with pypdf using the password test123 (2,638 bytes). Reading text without the password failed with FileNotDecryptedError. qpdf --decrypt --password=test123 locked.pdf unlocked-qpdf.pdf produced a 2,163-byte file that opens with no password, all 3 pages intact. A wrong password failed at once: qpdf exited with code 2 and printed invalid password. The pypdf route gave the same result at 2,239 bytes:
from pypdf import PdfReader, PdfWriter
reader = PdfReader('locked.pdf')
reader.decrypt('test123')
writer = PdfWriter()
for page in reader.pages:
writer.add_page(page)
with open('unlocked.pdf', 'wb') as f:
writer.write(f)
What it can't do (tested)
- Forgotten passwords: neither qpdf nor pypdf recovers a password you do not know. There is no legitimate shortcut — try the passwords you might have used, or ask whoever set it.
- Someone else's protection: unlocking a file you do not own or have no right to unlock is not something these tools are for.
- Restrictions without a password: some PDFs open freely but forbid printing or copying.
qpdf --decryptwith no--passwordremoves those restrictions from a file you own — tested on a permissions-only file, which went from encrypted to open at 2,006 bytes. - Content changes: unlocking changes nothing inside the file — same pages, same text, just no password gate.
Free alternatives, honestly compared
- pikepdf: a Python binding for the same qpdf engine —
pikepdf.open('locked.pdf', password='test123')thenpdf.save('unlocked.pdf'). Same result, scriptable. - Adobe Acrobat Pro: File > Properties > Security can remove a password you know, with a point-and-click interface. It is paid; qpdf is free.
- Online unlockers: they upload your file to someone else's server. Never use one for bank statements, contracts, or anything sensitive — the file leaves your machine.
Frequently asked questions
I forgot the password. Can I unlock the PDF?
No legitimate tool recovers a forgotten password. qpdf and pypdf only remove a password you already know. Try passwords you might have used, or ask the person who set it.
Is it legal to unlock a PDF?
Unlocking a file you own, or one you have the right to use, is fine. Breaking the protection on someone else's file without permission is not.
My PDF opens fine but will not let me print. Can I fix that?
Yes. That is a permissions lock, not an open password. Run qpdf --decrypt locked.pdf unlocked.pdf with no --password and the restrictions are gone.
Will unlocking change the content?
No. The pages, text, and images stay exactly the same — only the password gate is removed.
Related guides: How to Rotate PDF Pages · How to Sign a PDF Online · How to Split a PDF · How to Merge a PDF · All guides · Tool: PDF Probe