Password-protect a PDF

Add a password so the file opens only for someone who has it, or take a password off one you can already open. The encryption is AES-256, and because it happens on your device the file and the password are never sent anywhere.

How it works

A password on a PDF is real encryption, not a setting. The contents of the file are enciphered with a key derived from the password, so a reader that does not have it has nothing to show: not the text, not the images, not the page count. This is worth stating because the other thing a PDF can carry looks similar and is not. A PDF can be marked "do not print" or "do not copy" while remaining completely unencrypted, and those flags are a request to the reader software rather than a restriction on the file. Any reader may ignore them, and plenty do. This tool sets a password, which is the kind that holds.

The encryption here is AES-256, which is the strongest the PDF specification defines and the only option offered. Older PDFs used RC4 at 40 or 128 bits, and those are broken well enough that the tool that does the encrypting refuses to write them without being explicitly told to. It is never told to. There is no cipher to choose and no key length to set, because there is exactly one defensible answer and presenting it as a decision would only invite a worse one.

The work is done by qpdf, a long-standing PDF tool compiled to WebAssembly and running inside this page. That matters more than it might sound: implementing PDF encryption by hand would mean writing cryptographic code for a security feature, which is the wrong thing to do no matter how carefully it is written or how thoroughly the algorithm is specified. Using an implementation that has been in use and under scrutiny for years is the whole point.

One password is set, and it is used both as the password that opens the document and as the one that governs permissions. A PDF can have two different passwords, and the distinction traps people constantly: a file with only an owner password opens for anybody who double-clicks it, while appearing in every summary as "password protected". If you set a password here, the file needs it to open. That is the only meaning it has.

Because the password never leaves the page, nothing can recover the file if it is lost. There is no reset, no recovery address and no copy kept anywhere, which is a direct consequence of the file never being uploaded. Write it down before you close the tab.

How to use it

  1. 1 Choose a PDF. If it already has a password, the tool notices and offers to take it off instead.
  2. 2 Type the password, and type it again so a mistyped one cannot lock you out.
  3. 3 Add the password, or remove it, and download the result.
  4. 4 Save the password somewhere. Nothing here can recover it.

Good to know

  • The encryption is AES-256, the strongest the PDF format defines. The weaker RC4 options are not offered.
  • One password, one meaning: the file needs it to open. There is no owner-only mode that leaves the document readable by everyone.
  • A password can be removed as easily as added, provided you can supply the current one.
  • A long password beats a complicated one. Length is what makes guessing impractical.
  • The file and the password are both processed on your device, so neither is ever transmitted or stored.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

The two passwords on a PDF, and why this tool only sets one

A PDF can carry two passwords, and almost every problem people have with protected PDFs comes from not knowing that. The user password is the one that decrypts the document: without it there is nothing to display, because the content streams are ciphertext. The owner password governs permissions (printing, copying, annotating) and a file can carry an owner password while having no user password at all. Such a file opens for anybody who double-clicks it, shows every word, and still reports itself as "password protected" in every summary that bothers to look. This tool sets the same string as both, so the only meaning a password has here is the one people expect: the file needs it to open.

That distinction matters more than it sounds, because the permissions half is not enforced by cryptography. The flags that say "do not print" are stored in the encryption dictionary, and honouring them is a request to the reader software. The specification says a conforming reader should obey them; nothing stops one that does not, and the flags are readable without any password when only an owner password is set. Any tool that offers to "restrict printing" without encrypting is offering a preference, not a protection, and this one does not offer it.

The encryption is AES-256, which in PDF terms means a security handler of revision 6: `/V 5 /R 6 /AESV3` in the encryption dictionary, which you can see in the output with any hex viewer. The alternative the format still permits is RC4 at 40 or 128 bits, and qpdf, which does the work here, refuses to write those without an explicit `--allow-weak-crypto`. That flag is never passed. Asking for `--bits=128` therefore fails outright rather than quietly producing a weaker file, which is the correct behaviour and the reason there is no key-length control in the interface: there is one defensible answer, and presenting it as a choice would only invite a worse one.

The password itself is capped at 127 bytes, and the tool rejects anything longer instead of accepting it. This is not an arbitrary limit, because the standard truncates at that length, so a longer password would be silently cut down, and the file would then open with a prefix of what was typed rather than the whole thing. A user who pasted a 200-character passphrase would have a file that refuses the passphrase they think protects it. The limit is measured in bytes rather than characters, which matters as soon as the password contains anything outside ASCII: an emoji is four bytes, so thirty-two of them are already over.

None of the cryptography is ours. qpdf is compiled to WebAssembly and runs inside the page, which is a deliberate choice rather than a convenience: implementing PDF encryption by hand would mean writing cryptographic code for a security feature, and the fact that the algorithm is fully specified does not make that a reasonable thing to do. The trade-off is that qpdf’s only WebAssembly build imports shared memory, so the page has to be cross-origin isolated to run it at all. That is why this route is served with COOP and COEP headers and carries no advertising: the isolation that makes threads available is the same isolation that blocks third-party scripts.

Everything happens on the device, which has a consequence worth stating plainly rather than burying. The password is never transmitted and never stored, so there is no reset, no recovery address and no copy anywhere. A forgotten password means the file is gone, and that is not a limitation of this implementation; it is what encryption is. The same property that makes it safe to protect a document here makes it impossible to rescue one.

Frequently asked questions

Is this real encryption, or just a restriction flag?

Real encryption. The contents are enciphered with AES-256 using a key derived from your password, so a reader without it cannot show the text or the images. That is different from the "do not print" and "do not copy" flags a PDF can also carry, which are unencrypted requests to the reader software and can be ignored by any program that chooses to.

What happens if I forget the password?

The file cannot be opened, by you or by us. The password is never sent anywhere and nothing is stored, so there is no reset and no recovery. That is the same property that makes the tool safe to use, and it cuts both ways. Write the password down before you close the tab.

Can I remove a password from a PDF?

Yes, if you can supply the password it currently opens with. Choose the file and the tool will notice it is protected and offer to take the password off. It cannot remove a password you do not know: that would not be encryption.

Which encryption does it use?

AES-256, and nothing else. It is the strongest the PDF specification defines. The older RC4 options at 40 and 128 bits are considered broken, and the underlying tool refuses to write them without an explicit override, which this tool never gives it.

Why does it ask for the password twice?

Because a typo in a password you cannot see produces a file that opens with something you do not know, and you would not find out until the next time you needed it. Typing it twice catches that while it still costs nothing.

Is my file uploaded?

No. The PDF is read, encrypted and handed back inside this browser tab by your own device, and the password never leaves the page either. You can watch your browser’s Network tab while it works: nothing carrying the file or the password goes out.

Related tools

How this tool was built — a step-by-step account of the engine, the code and what went wrong.

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.