Clioos › Guides › Unlock PDF

How to Unlock a PDF

By Clioos Team

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

Steps

  1. Install qpdf (free, open source): on Linux sudo apt install qpdf; on macOS brew install qpdf. The test used qpdf 11.9.0.
  2. Check the file: qpdf --check locked.pdf reports the encryption. On the test file, pypdf also reported the file as encrypted and refused to read text without the password.
  3. Unlock it: qpdf --decrypt --password=test123 locked.pdf unlocked.pdf — the unlocked file is written separately, the original is untouched.
  4. 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.
  5. 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)

Free alternatives, honestly compared

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