How to use the Base64 to PDF tool
- Paste the string from your API response, email source or database field into the Base64 or Base64 data URL box.
- Select Decode file to decode it and test for a PDF header.
- Check the Result line, which shows the document size and application/pdf.
- Select Download to save decoded.pdf, then open it in your PDF reader.
How to recognize Base64 PDF data
A PDF file starts with a header line: the five characters %PDF- followed by a version number such as 1.4, 1.7 or 2.0. Base64 turns %PDF- into JVBERi0, so an encoded PDF is easy to spot. Version 1.x documents begin with JVBERi0xLj and version 2.0 documents with JVBERi0yLj.
This tool decodes the input and requires %PDF- at the very first byte. On success it shows the size, labels the data application/pdf and offers decoded.pdf. There is no on-page preview for PDF; open the downloaded file to read it.
Worked example: a blank one page PDF
The Base64 below is a complete, minimal PDF of 329 bytes: a catalog, a page tree, one empty 200 by 200 point page, a cross-reference table and a trailer. It starts with JVBERi0xLjQK, which is the header line %PDF-1.4 and a line feed. The last line of the decoded file is the end marker %%EOF.
JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4K
ZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50
IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAv
TWVkaWFCb3ggWzAgMCAyMDAgMjAwXSA+PgplbmRvYmoKeHJlZgowIDQKMDAwMDAwMDAw
MCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAK
MDAwMDAwMDExNSAwMDAwMCBuIAp0cmFpbGVyCjw8IC9TaXplIDQgL1Jvb3QgMSAwIFIg
Pj4Kc3RhcnR4cmVmCjE4NgolJUVPRgo=
Result: 329 bytes · application/pdf
File: decoded.pdfWhy Base64 to PDF conversion fails
The message The Base64 does not contain a PDF file means decoding worked but byte 0 is not the start of %PDF-. The list shows typical causes.
A different message, Enter valid Base64 or Base64URL data, means the text itself is damaged: an escaped slash or newline copied from JSON source, a percent-encoded plus sign, or a missing character.
- The API returned an error. JSON starts with eyJ or ewo, and HTML error pages start with PCFET0NUWVBF or PGh0bW.
- Extra bytes precede the header, such as a UTF-8 byte order mark (77u/ in Base64) or a blank line. PDF readers often tolerate that; this check does not.
- The value was encoded twice, so the first decode yields text beginning with JVBERi0. Decode that text again.
- The field holds a different document type. UEsDB means a ZIP based file such as DOCX.
Where Base64 encoded PDFs come from
Shipping label, invoicing and e-signature APIs return documents as a Base64 field so the response can stay pure JSON. Email stores PDF attachments as Base64 MIME parts, wrapped at 76 characters per line, and you can paste such a block directly because line breaks are ignored.
In each case decoding gives back the exact file, including digital signatures, form fields and encryption. A password-protected PDF decodes without the password; the reader asks for it when you open the file.
Frequently asked questions
Is my PDF uploaded to the server?
No. The document is decoded in your browser and saved from memory. That makes the tool suitable for invoices, contracts and statements that should not pass through a third party.
Can I preview the PDF before downloading?
Not on this page. The tool shows the size and type, then provides a Download link. Open decoded.pdf in your browser or PDF reader to view the pages.
Why does my decoded PDF open as damaged?
Only the header is checked, so a string that was cut short still passes. A complete PDF ends with a %%EOF marker after the cross-reference data. If the byte count is lower than the original file size, fetch the full value again.
How do I decode Base64 from a data URL?
Paste the whole URL, starting with data:application/pdf;base64, and select Decode file. The prefix is removed automatically. Pasting only the part after the comma gives the same result.
Does the tool accept URL-safe Base64 PDFs?
Yes. If the string contains - or _ it is decoded with the Base64URL alphabet, and padding may be omitted. Strings that mix both alphabets are rejected as invalid.
How large a PDF can I decode?
There is no limit in the code. The practical bound is browser memory, which has to hold the pasted text and the resulting bytes. Expect the Base64 to be about 33% larger than the PDF.