Base64 → PDF
Base64 to PDF, without sending the document anywhere.
Paste the Base64 from an API response, a database field or an email source. The PDF is rebuilt in your browser, shown in the preview, and saved as a normal .pdf file when you press Download. Invoices, contracts and labels never leave your device.
Updated · Runs entirely in your browser
Base64 to PDF converter
JSON Web Token
Options
Ctrl+Enter decode Ctrl+Shift+C copy result Drop a file anywhere on the input to load it
How to convert Base64 to PDF
- 01
Paste the Base64 PDF
Paste the encoded document, with or without a data:application/pdf;base64, prefix. Line breaks from email sources are stripped automatically.
- 02
Confirm it is a PDF
The Type field shows “PDF document” when the decoded bytes start with the %PDF signature. Your browser renders it in the Preview tab.
- 03
Download the .pdf file
Press Download to save the document as a .pdf, or open it in a new tab from the preview.
Where Base64 PDFs come from
JSON cannot carry raw bytes, so APIs that return documents — e-signature, invoicing, payroll, shipping label and reporting services — usually put the PDF in a string field as Base64. Email does the same: a PDF attachment travels as Base64 inside the MIME source, wrapped at 76 characters per line. Both decode here exactly as they are; you do not need to remove line breaks first.
How to tell a Base64 string is a PDF
Every PDF begins with %PDF-, and in Base64 that always becomes JVBERi0. If
your string starts with those seven characters, it is a PDF. Other prefixes tell you what you have instead:
| Format | Base64 starts with | First bytes (hex) |
|---|---|---|
JVBERi0 | 25 50 44 46 2d (%PDF-) | |
| ZIP / DOCX / XLSX | UEsDB | 50 4b 03 04 (PK) |
| Gzip | H4sI | 1f 8b 08 |
| PNG | iVBORw0KGgo | 89 50 4e 47 0d 0a 1a 0a |
| JPEG | /9j/ | ff d8 ff |
UEsDB means a ZIP container, which is also what Word and Excel files are. H4sI
means the document was gzip-compressed before it was encoded — download the result as a .gz file and
decompress it to reach the PDF.
Fixing a PDF that will not open
- Copied from raw JSON. JSON may escape the slash as
\/. Copy the value from a parsed view (or replace\/with/) — a backslash is not valid Base64. - Truncated. A complete PDF ends with
%%EOF. If the Hex tab shows the document stopping short, the Base64 was cut off; the PDF reader will report it as damaged. - Encoded twice. If the result starts with
JVBERi0as text, it was Base64 encoded twice. Press Send to input and decode again. - Password protected. Decoding restores the file exactly; if it was encrypted, the PDF reader will still ask for its password.
Decode Base64 to PDF in code
# Python
import base64
with open("document.pdf", "wb") as f:
f.write(base64.b64decode(response["pdf"]))
// Node.js
fs.writeFileSync("document.pdf", Buffer.from(json.pdf, "base64"));
# Shell, straight from an API response
curl -s https://api.example.com/invoice/42 | jq -r .pdf | base64 --decode > invoice.pdf
See the full set of Base64 decode examples for Java, C#, PHP, Go and PowerShell.
More decoders
Other ways to decode Base64.
- Base64 decode Decode any Base64 to text, an image or a file, with 20+ character sets.
- Base64 to image Preview a Base64 PNG, JPEG, GIF, WebP or SVG and save it as a real image file.
- Base64 to hex See every decoded byte as a hex dump, or copy it as one continuous hex string.
- Base64URL decode Decode URL-safe Base64 and JSON Web Tokens, with missing padding repaired.
Questions
Base64 to PDF: common questions.
How do I convert a Base64 string to a PDF?
Paste the Base64 into the input box on this page. It is decoded in your browser, identified as a PDF from its %PDF signature, and shown in the preview. Press Download to save it as a .pdf file.
Why does my decoded PDF say it is damaged?
Almost always because the Base64 was truncated or altered when it was copied. A complete PDF ends with %%EOF. Copy the value again from the original source rather than from a log or a spreadsheet cell, and check that JSON escapes such as \/ were removed.
Is it safe to decode confidential PDFs here?
Yes. The document is decoded by JavaScript in your own browser and previewed from a local blob URL. It is never uploaded, logged or stored, so invoices, contracts and medical letters stay on your device.
Is there a size limit for Base64 PDFs?
There is no server limit because nothing is uploaded. Use the File button for very large Base64 text files; the practical ceiling is your device memory.