Base64 to PDF Decoder
Paste a base64 string or data URL, decode it back into a real PDF, and download the file — validated and decoded entirely in your browser, with nothing uploaded.
- Free
- No account
- Runs in your browser
- Nothing uploaded
Runs entirely in your browser — your input is never uploaded, logged, or stored.Privacy policy
What is Base64 to PDF Decoder?
Base64 is a text encoding of binary data, and it turns up wherever a PDF has to travel through a channel that only carries text: an API response that returns a document as a JSON field, a database column holding an attachment, an email or a support ticket, a log, or a data URL in a web page. Tools like this site's Image to Base64 Converter produce those strings; this tool reverses the process for PDFs specifically.
Paste a base64 payload — on its own, or as a full data:application/pdf;base64,… URL — and the tool decodes it back to the exact bytes it encodes. Newlines and spaces inside the string are ignored, and a missing trailing padding character is restored, because base64 copied out of an email or a wrapped console output is usually broken across lines. When the payload carries a data:…;base64, prefix, the prefix is stripped and the payload read from it.
A base64 string can decode to anything, so the tool checks the result twice before it hands it over. First it looks for the PDF header, the characters %PDF- that every PDF file begins with. Then it opens the bytes with pdf-lib, the same open-source library the site's other PDF tools use, which parses the file's internal structure. Only if both checks pass does it report the page count and offer the download. That two-step check is why the tool can tell you the bytes are "not a PDF" (a PNG signature, say) separately from a PDF that is "damaged or incomplete".
The download is the decoded bytes, byte for byte — nothing is re-saved, re-compressed or rebuilt, so the PDF you get back is identical to the file that was encoded. Decoding happens locally in your browser; the string is never sent to a server, which makes it safe for PDFs that came out of private or production systems. This tool decodes and validates a PDF. It does not repair one: if the file is genuinely damaged, it says so and explains why, rather than pretending to fix it or handing you a corrupt download.
A base64 PDF can be a bare payload or a data URL:
data:application/pdf;base64,<payload>
1. An optional data:…;base64, prefix is stripped, and the payload read from it. 2. All whitespace — spaces, tabs and the newlines a wrapped string carries — is removed. 3. The payload is checked against the base64 alphabet and decoded, 4 characters (3 bytes) at a time. A missing trailing `=` is restored; a length one short of a multiple of 4 cannot come from valid base64 and is refused. 4. The decoded bytes are checked for the %PDF- header in the first 1,024 bytes — the window PDF readers themselves search, to tolerate a little leading junk. 5. The bytes are opened with pdf-lib, which parses the cross-reference table and page tree, so a file that merely starts with %PDF- but is truncated is catchable as damaged. 6. The decoded file is held in memory, the page count is read from the parsed document, and the download is offered.
Base64 inflates binary data by about a third as it encodes it into text, so the reverse is true when you decode: the PDF you download is roughly three-quarters the length of the string you pasted. The reported byte length is the true decoded size — the size of the file you get, not the size of the string.
Worked examples
- A real two-page PDF built with pdf-lib, base64-encoded → decoded back to the byte-identical PDF and reported as 2 pages.
- The same base64 string wrapped with spaces and line breaks → the whitespace is stripped and the same two-page PDF comes back.
- data:application/pdf;base64,<the same payload> → the data: prefix is recognised and stripped; same bytes, same 2 pages, prefix reported.
- iVBORw0KGgo= (the 8-byte PNG signature, which is valid base64) → refused with “The decoded bytes are not a PDF — …”, because the bytes are not a PDF.
- An empty box, or a string of only spaces and newlines → refused with “Paste a base64 string first — the input is empty.”
How to use Base64 to PDF Decoder
- Copy the base64 string, or the whole data:application/pdf;base64,… URL, that holds the PDF.
- Paste it into the box. Line breaks and spaces inside the string are ignored, so a wrapped paste is fine.
- Click Create PDF. The tool decodes the bytes, checks for the PDF header, and opens the file to confirm it is a real PDF.
- Check the page count and the decoded size it reports, then click Download to save the PDF.
Common errors
- "Paste a base64 string first — the input is empty." — the box was blank, or held only spaces and line breaks. Paste the base64 string itself, then click Create PDF.
- "That is not valid base64 — check for characters outside A–Z, a–z, 0–9, + and /, and make sure you copied the whole string." — a stray character such as @, !, or a curly quote slipped in, or the copy was cut short. Re-copy from the source; whitespace inside the string is fine, but nothing else is.
- "The decoded bytes are not a PDF — a PDF file starts with the characters %PDF-. This string decodes to something else, so check you pasted the right base64." — the string is valid base64 but it is an image, text or some other file. An image belongs in Base64 to Image.
- "The base64 decoded to PDF bytes, but the file could not be opened — it is damaged or incomplete. This tool cannot repair a broken PDF." — the bytes start with %PDF- but the structure inside is broken or truncated. This tool decodes; it does not repair. Get a fresh copy of the original file.
- "That PDF is larger than this tool allows: the limit is 200 MB. The whole file is held in your browser's memory, and very large PDFs can crash the tab." — everything runs in the browser, so a very large PDF is refused before it can exhaust memory. Compress the PDF, then encode and decode it again.
- "This PDF is encrypted (password-protected), so it cannot be opened here. Remove the password in a PDF reader, save an unprotected copy, and decode that instead." — an encrypted PDF's pages are ciphertext, so there is nothing to validate. Remove the password, then base64-encode the unprotected copy and decode that.
FAQ
Where does my base64 string go?
Nowhere. The string is decoded and validated entirely in your browser with pdf-lib. Nothing is uploaded to a server, so it is safe to decode base64 PDFs that came from private databases, API responses or production systems.
Do I need to include the data:application/pdf;base64, prefix?
No. The tool accepts the bare base64 payload on its own and as a full data URL. The prefix is only stripped; whether it is present or not, the bytes are what decide whether the result is a PDF.
Will the downloaded PDF be identical to the original file?
Yes. Base64 is an exact, lossless encoding of the original bytes, and the tool downloads the decoded bytes unchanged — it does not re-save or rebuild the PDF. The file you get back is byte-for-byte identical to the one that was encoded.
Why does the tool say the decoded bytes are not a PDF?
Because they are not. Valid base64 can encode any bytes, and a PDF always begins with the characters %PDF-. If the decoded bytes start with a PNG signature, plain text or anything else, the string holds a different kind of file — an image belongs in the Base64 to Image tool instead.
Can it repair a damaged or password-protected PDF?
No. This tool decodes and validates; it does not repair. A PDF whose bytes start with %PDF- but whose internal structure is broken is reported as damaged, and an encrypted PDF is refused because its pages are ciphertext. Remove a password in a PDF reader and re-encode the unprotected copy, or get a fresh copy of a damaged file.
Why is the downloaded file smaller than the string I pasted?
Base64 inflates binary data by about 33% when it turns bytes into text, so decoding reverses that: the PDF is roughly three-quarters the length of the string. The decoded byte length the tool reports is the true size of the file you download.
Related tools
- Base64 to Image ConverterPaste a base64 string or data URL, preview the image it encodes, and download it as a file — decoded entirely in your browser.
- Base64 Encoder & DecoderEncode text to Base64 or decode Base64 strings back to text instantly.
- JPG to PDF ConverterAdd JPG or other images, put them in page order, choose a page size, and download one PDF — built on your own device, nothing uploaded.
Prefer AllUtil on Google
One click adds AllUtil to your Google preferences. You'll see our tools highlighted with a Preferred badge in Search and AI answers.