How to use
- Paste the Base64 string, or a data URI starting with data:application/pdf;base64, into the input box.
- Check that the file is detected as PDF and read it in the viewer.
- Download the PDF to save it on your device.
Copying Base64 out of an API response
Services that generate invoices, shipping labels, reports or signed contracts often return the PDF inside JSON, for example {"filename": "label.pdf", "data": "JVBERi0..."}. Copy only the text between the quotation marks after the field name, and watch for these details:
- Escaped slashes. Some JSON encoders, PHP's
json_encodeamong them, write every/as\/. Since/is a normal Base64 character, replace\/with/before pasting, or parse the JSON first and copy the value. - Quotes and commas. Leave out the surrounding quotation marks and any trailing comma.
- Line breaks. Spaces and real line breaks inside the Base64, such as a value wrapped at 76 characters, are fine and do not need to be removed. Literal
\nor\r\nsequences in raw JSON are a different matter: they are backslash characters and must be deleted.
Copying the value from the parsed view in your browser's developer tools avoids all of these escaping problems.
Extracting a PDF attachment from an email
Email attachments are stored as Base64 inside the raw message. Open the message source ("Show original" in Gmail, "Message Source" in Thunderbird, "Raw Source" in Apple Mail) and find the part whose headers include Content-Type: application/pdf (or application/octet-stream with a .pdf file name) and Content-Transfer-Encoding: base64. Copy the block that starts after the blank line below those headers and ends before the next line beginning with --, which is the MIME boundary. Paste it here as it is; the line breaks are ignored.
Showing a Base64 PDF in your own web app
When your front end receives a Base64 PDF and needs to display it, a Blob URL is more reliable than a data URI, which some browsers refuse to open in a new tab:
const bytes = Uint8Array.from(atob(base64), c => c.charCodeAt(0));
const blob = new Blob([bytes], { type: 'application/pdf' });
const url = URL.createObjectURL(blob);
window.open(url); // or use it as the src of an <iframe>
Call URL.revokeObjectURL(url) once the document is no longer needed to release the memory. Note that atob only accepts the standard Base64 alphabet, so convert URL-safe input (- and _) first.
Frequently asked questions
Why is my Base64 not detected as a PDF?
JVBERi0, the encoding of %PDF-. If yours starts with a quote, a field name or other text, remove it. If it starts with SlZCRVJ, the PDF was Base64-encoded twice: decode it once with the Base64 decoder and paste the result here. Otherwise the data may be another file type, which Base64 to File can identify.The PDF downloads but will not open. What went wrong?
Most likely the Base64 was cut off. Logs, consoles and database tools often truncate long values, and a PDF that is missing its end cannot be read, because the cross-reference table that locates every page is stored near the end of the file. Copy the complete value again, ideally by saving the original response to a file.
The preview is blank on my phone. Is the file broken?
Not necessarily. Some mobile browsers cannot display a PDF inside a page. Download the file and open it in a PDF reader to check it.
Can I decode a password-protected PDF?
Yes. Decoding restores the file byte for byte, including its encryption. The preview may ask for the password or stay empty, and the downloaded file opens in any PDF reader once you enter the password.
Is the document uploaded anywhere?
No. Decoding and the preview happen in your browser, so confidential PDFs such as contracts, payslips or medical records stay on your device.