A locked PDF that requires a password every time you open it is inconvenient enough. A permissions-locked PDF that refuses to let you print or fill in fields is worse. Both problems have the same solution: remove the password.
This guide covers every method, from a free browser tool to the command line, with code examples for automating the process at scale.
What does "removing a PDF password" mean?
Removing a PDF password means decrypting the file and saving an unencrypted copy. The PDF specification (ISO 32000-1, Section 7.6) defines two types of passwords: an open password (user password) that prevents the file from being opened, and an owner password (permissions password) that restricts editing, printing, or copying without blocking access. Both are part of the PDF's security handler.
When you decrypt the file, the security handler is stripped out entirely. The output PDF is identical in content but has no access restrictions.
Why you might need to remove a password
| Scenario | Why decryption is needed |
|---|---|
| Compress a large PDF | Most compression tools reject encrypted input |
| Merge multiple PDFs | pdf-lib and most merge tools cannot read locked files |
| Fill in a form | Owner password may block form filling |
| Share without friction | Remove the requirement for recipients to enter a password |
| Archival / PDF/A conversion | PDF/A forbids encryption (Library of Congress format description for PDF/A-1) |
| Batch processing | Automated pipelines cannot prompt for passwords interactively |
Method 1: PDF4.dev browser tool (fastest, no install)
Unlock PDF removes both open and owner passwords directly in your browser. The file is never sent to a server: decryption happens inside your browser using pdf-lib running in WebAssembly.
- Go to pdf4.dev/tools/unlock-pdf
- Drop your PDF onto the upload area
- Enter the correct password
- Click Unlock PDF and download the result
What it handles:
- Open passwords (file requires a password to view)
- Owner passwords (file opens freely but editing or printing is restricted)
- Both simultaneously
What it does not handle:
- Passwords you do not know (correct password is always required)
- Corrupt or non-standard PDF encryption not supported by pdf-lib
The output is a standard, unencrypted PDF that opens in Preview, Adobe Reader, Chrome, or any other viewer with no prompts.
Method 2: qpdf (command line, all encryption types)
qpdf is a free, open-source command-line tool that handles every PDF encryption variant, including RC4-40, RC4-128, AES-128, and AES-256. It is the most reliable option for all encryption types and for automation.
# Remove password from a PDF
qpdf --decrypt --password=yourpassword input.pdf unlocked.pdfIf the PDF only has an owner password (opens freely but has editing restrictions), you may be able to decrypt without supplying anything:
# Attempt decryption when no open password is set
qpdf --decrypt input.pdf unlocked.pdfInstall on macOS:
brew install qpdfInstall on Ubuntu/Debian:
sudo apt install qpdfInstall on Windows via Chocolatey:
choco install qpdfBatch removal with qpdf
To process a folder of locked PDFs, pass the same password across all files in a shell loop:
# Bash: decrypt all PDFs in a folder
for f in *.pdf; do
qpdf --decrypt --password=yourpassword "$f" "unlocked_$f"
done# PowerShell: decrypt all PDFs in a folder
Get-ChildItem -Filter *.pdf | ForEach-Object {
qpdf --decrypt --password=yourpassword $_.Name "unlocked_$($_.Name)"
}qpdf exits with code 0 on success and non-zero on failure, making it easy to integrate into CI pipelines and automated document workflows.
Method 3: Node.js with pdf-lib
pdf-lib is a pure JavaScript library that supports reading and writing encrypted PDFs. This is the same library powering PDF4.dev's browser tools.
import { PDFDocument } from "pdf-lib";
import { readFileSync, writeFileSync } from "fs";
async function removePdfPassword(
inputPath: string,
outputPath: string,
password: string
): Promise<void> {
const encryptedBytes = readFileSync(inputPath);
// Load the PDF with the correct password
const pdfDoc = await PDFDocument.load(encryptedBytes, {
password,
ignoreEncryption: false,
});
// Save without encryption (no password set = unencrypted output)
const unencryptedBytes = await pdfDoc.save();
writeFileSync(outputPath, unencryptedBytes);
console.log(`Unlocked: ${outputPath}`);
}
// Usage
await removePdfPassword("protected.pdf", "unlocked.pdf", "your-password");Install pdf-lib:
npm install pdf-libHandling errors gracefully
If the password is wrong, pdf-lib throws during the load() call. Wrap it in a try/catch for production use:
import { PDFDocument, PasswordContext } from "pdf-lib";
async function unlockPdf(
pdfBytes: Uint8Array,
password: string
): Promise<Uint8Array | null> {
try {
const pdfDoc = await PDFDocument.load(pdfBytes, { password });
return await pdfDoc.save();
} catch (err) {
if (err instanceof Error && err.message.includes("password")) {
console.error("Incorrect password");
return null;
}
throw err;
}
}Method 4: Python with pypdf
pypdf is the most popular PDF library for Python. It handles both encrypted open and owner passwords.
from pypdf import PdfReader, PdfWriter
def remove_pdf_password(input_path: str, output_path: str, password: str) -> bool:
reader = PdfReader(input_path)
if reader.is_encrypted:
success = reader.decrypt(password)
if not success:
print("Incorrect password")
return False
writer = PdfWriter()
for page in reader.pages:
writer.add_page(page)
with open(output_path, "wb") as f:
writer.write(f)
print(f"Unlocked: {output_path}")
return True
# Usage
remove_pdf_password("protected.pdf", "unlocked.pdf", "your-password")Install pypdf:
pip install pypdfpypdf's decrypt() method returns an integer: 0 means failure (wrong password), 1 means the user password matched, 2 means the owner password matched. Check the return value explicitly in production code.
Method 5: macOS Preview (no install, no account)
macOS ships with Preview, which can export a PDF without its password:
- Open the password-protected PDF in Preview (enter the password when prompted)
- Go to File → Export as PDF
- In the save dialog, leave the Encrypt checkbox unchecked
- Click Save
The exported file has no password. This is the simplest method on a Mac for a one-off task, but it does not scale to batch operations.
Choosing the right method
| Method | Platform | Batch support | AES-256 | Cost | File leaves device |
|---|---|---|---|---|---|
| PDF4.dev browser tool | Any browser | No | Yes | Free | Never |
| qpdf (CLI) | Mac, Linux, Windows | Yes | Yes | Free | Never |
| pdf-lib (Node.js) | Any | Yes | Partial | Free | Depends on deployment |
| pypdf (Python) | Any | Yes | Yes | Free | Depends on deployment |
| macOS Preview | Mac only | No | Yes | Free (macOS) | Never |
| Adobe Acrobat | Mac, Windows | No | Yes | Paid | Never |
For most one-off tasks, the Unlock PDF browser tool is fastest. For automation or batch decryption, qpdf with a shell loop is the most reliable option.
What you cannot do: removing a password without knowing it
Removing a strong PDF password without knowing it is not practically possible. Here is what each encryption type means in terms of resistance:
| Encryption | Key size | Practical attack |
|---|---|---|
| RC4-40 | 40-bit | Crackable in seconds with modern hardware |
| RC4-128 | 128-bit | Dictionary/brute-force if password is short or weak |
| AES-128 | 128-bit | Only weak passwords are recoverable |
| AES-256 | 256-bit | Effectively uncrackable with any strong password |
The Electronic Frontier Foundation's work on encryption strength and the NIST AES specification (FIPS 197) confirm that AES-256 with a strong password has no known practical attack. If you have lost access to your own document and it uses AES-256, the file is unrecoverable without the password.
For older PDFs using RC4 or very short passwords, tools like pdfcrack (open-source, free) can attempt dictionary and brute-force attacks. This only makes sense if you own the file and have simply forgotten the password.
Removing permissions restrictions (owner password)
Some PDFs open without any password but restrict editing, printing, or form filling. These documents have an owner password but no user password. The restrictions are enforced by any PDF viewer that respects them, but the file content is technically readable.
qpdf handles this cleanly:
# Remove permissions/owner password restrictions
qpdf --decrypt input.pdf unrestricted.pdfIf the PDF has no user password, qpdf can decrypt it without supplying any password at all. This removes the restrictions handler and produces a fully unrestricted PDF.
pdf-lib also handles this case: loading an owner-password-only PDF with an empty password string often works, though the behavior depends on how the original tool implemented the security handler.
After removing the password: common next steps
Once you have an unlocked PDF, you can do things that encrypted files block:
Compress the file: Most compression tools reject encrypted PDFs. Compress PDF requires an unencrypted input.
Merge multiple PDFs: The Merge PDF tool and pdf-lib's copyPages() method both need unencrypted inputs.
Re-protect with a stronger password: If you unlocked to modify the document, you can re-add a password with Protect PDF after making your changes. See the full guide on how to password protect a PDF for encryption options.
Convert to PDF/A: Archival conversion requires removal of the security handler since PDF/A explicitly forbids encryption.
Automating password removal with the PDF4.dev API
If you generate password-protected PDFs through an API and later need to distribute unlocked copies, you can handle decryption in your application before delivery. For generating PDFs programmatically from HTML templates, the PDF4.dev API creates unencrypted PDFs by default, which you can then optionally protect at distribution time:
// Generate a PDF, then conditionally protect it
const response = await fetch("https://pdf4.dev/api/v1/render", {
method: "POST",
headers: {
Authorization: "Bearer p4_live_...",
"Content-Type": "application/json",
},
body: JSON.stringify({
template_id: "invoice",
data: { invoice_number: "INV-001", total: "$1,500.00" },
}),
});
const pdfBuffer = await response.arrayBuffer();
// pdfBuffer is unencrypted — protect it with pdf-lib or qpdf before deliveryThis pattern gives you full control: generate once, distribute in different forms (protected, watermarked, or unrestricted) based on recipient permissions.
PDF4.dev generates PDFs from HTML templates via a REST API. No Chromium to manage, no Docker required. Sign up free and generate your first invoice, certificate, or report in under a minute.
FAQ
Can I remove a PDF password for free?
Yes. PDF4.dev's Unlock PDF tool is free and runs entirely in your browser. Your file is never uploaded to a server. You need to know the correct password to remove it.
Can I remove a PDF password without knowing it?
Only if you own the document and have legal rights to access it. There is no practical way to bypass strong AES-256 encryption. Weak or short passwords may be recoverable with tools like pdfcrack, but modern strong passwords are effectively uncrackable.
What is the difference between removing an open password and an owner password?
An open password (user password) prevents the file from being opened at all. An owner password (permissions password) allows opening but restricts editing, printing, or copying. qpdf and pdf-lib can remove both once you supply the correct password.
Does removing the password change the PDF content?
No. Text, images, fonts, and layout are unchanged. Decryption only removes the security handler; the document content is identical to the original.
Can I remove a password from a PDF on iPhone or Android?
Yes. Use pdf4.dev/tools/unlock-pdf in Safari or Chrome on your phone. The tool runs in the browser with no app required. Enter the password and download the unlocked file.
Why do I need to remove a password from my own PDF?
Common reasons: you need to compress or merge the file, you want to fill in a form locked by an owner password, or you want to share the document without requiring recipients to enter a password.
What happens if I enter the wrong password?
The tool returns an error. pdf-lib throws a decryption failure if the supplied password does not match. No data is modified.
Is it legal to remove a PDF password?
Removing a password from a PDF you own or have permission to access is legal in most jurisdictions. Bypassing copy protection on a document you do not have rights to may violate copyright law or computer fraud statutes depending on your country.
How do I compress a password-protected PDF?
Remove the password first using the Unlock PDF tool, then compress the resulting file with Compress PDF. Most compression libraries cannot process encrypted PDFs.
Can I automate PDF password removal with code?
Yes. Use qpdf on the command line (qpdf --decrypt --password=yourpassword input.pdf output.pdf) or the pdf-lib library in Node.js. Both support batch processing across hundreds of files.
Free tools mentioned:
Start generating PDFs
Build PDF templates with a visual editor. Render them via API from any language in ~300ms.