Base64 to PDF Converter.
Paste a Base64-encoded PDF to open it in a new tab or download as .pdf.
PDF in Base64 commonly comes from API responses that embed generated documents (invoices, receipts, reports) inside JSON. A genuine PDF always starts with %PDF- (hex 25 50 44 46 2D). Decoded PDFs are opened via a blob URL — your file never touches a server.
We detect the %PDF- header so you know the bytes are actually a valid PDF before downloading.
Updated 9 November 2026
Paste the Base64 string, or a data:application/pdf;base64, URI, into the box above, then open or download the PDF. A Base64-encoded PDF almost always starts with JVBERi0, which is the encoded form of the %PDF- header. If yours starts with something else, the data probably isn't a PDF. Try Smart Detect. Other file types: see the Base64 file-signature table.
Why your Base64 PDF won't open.
If the decoded file is blank, corrupt or won't open, it's almost always one of these five problems.
- The data URI prefix is still attached.
data:application/pdf;base64,isn't part of the Base64. This tool strips it, but most code doesn't. Remove everything up to and including the comma. - JSON escaping survived. API responses often contain
\n,\r\nor\/inside the string. Parse the JSON first, or replace\/with/and remove the escaped line breaks. - The bytes were decoded as text. A PDF is binary. Decoding to a UTF-8 string and then saving it changes bytes and corrupts the file. Write the decoded bytes straight to disk (see the code below).
- The string was cut off. Logs, consoles and database columns truncate long values. A complete PDF ends with
%%EOF. If it's missing, fetch the full value again. - It was encoded twice. If the string starts with
SlZCRVJp, that's the Base64 ofJVBERi: the PDF was Base64-encoded twice. Decode it, then decode the result again.
Other prefixes tell you what you actually have: UEsDB is a ZIP (or a DOCX/XLSX, which are ZIP files), iVBORw0KGgo is a PNG and /9j/ is a JPEG.
Convert Base64 to PDF in your language.
PythonFull Python guide →
import base64
with open("output.pdf", "wb") as f:
f.write(base64.b64decode(b64_string))
JavaScript (Node.js)Full JavaScript guide →
const fs = require("fs");
fs.writeFileSync("output.pdf", Buffer.from(b64String, "base64"));
Linux / macOSFull Linux and macOS guide →
base64 -d input.b64 > output.pdf # older macOS: base64 -D
PowerShellFull PowerShell guide →
$b64 = Get-Content input.b64 -Raw
[IO.File]::WriteAllBytes("$PWD\output.pdf", [Convert]::FromBase64String($b64))
Going the other way? Use PDF to Base64.
About this tool.
PDF is binary, but many APIs return data as JSON, which can only contain text. Base64 lets servers embed a generated PDF (invoice, receipt, report, signed document) inside a JSON response. The client decodes it back to binary and offers a download.
PDF files always begin with %PDF- (hex 25 50 44 46 2D), followed by the version number. The tool checks for this signature before offering a download.
Yes — the "Open in new tab" button creates a blob URL and opens it in a new browser tab using the browser's built-in PDF viewer. The blob URL is local to your browser; the PDF never leaves the page.
PDFs can have their own encryption layer (separate from Base64). If you successfully decode the Base64 but the PDF asks for a password to view, the encryption is in the PDF itself, not the encoding. Use a PDF tool with the password to unlock it.
Blob with the application/pdf type, and create an object URL to download:const bytes = Uint8Array.from(atob(b64), c => c.charCodeAt(0));
const blob = new Blob([bytes], { type: 'application/pdf' });
const url = URL.createObjectURL(blob);Everything happens locally — nothing is uploaded.URL.createObjectURL() pins the blob in memory until the page is closed, so repeated downloads leak memory. Release it right after triggering the download:a.href = url; a.download = 'file.pdf'; a.click();
URL.revokeObjectURL(url);More from the toolkit.
Understanding Base64-encoded PDF.
Why APIs return PDFs as Base64
Modern APIs almost universally use JSON for request and response bodies, but JSON is a text format — it cannot contain raw binary data like a PDF. When a service generates a document (an invoice, a contract, a tax form, a medical report) and returns it inside a JSON response, the standard pattern is to Base64-encode the PDF into a string field. The client decodes that string back into binary bytes and either displays the PDF inline or offers it as a download.
This pattern is especially common in document signing services (DocuSign, HelloSign, Adobe Sign), invoicing platforms (Stripe Invoicing, QuickBooks, Xero), healthcare APIs (lab reports, prescriptions, claim documents), and government e-filing systems (tax returns, permits, certificates). The PDF stays opaque to the API layer — services do not need to parse it, just shuttle it through.
Recognizing a valid PDF by its bytes
Every valid PDF begins with the bytes %PDF- followed by a version number, like %PDF-1.7 or %PDF-2.0. After Base64 encoding, this header appears as JVBERi0 at the start of the string — a reliable signature that you have a PDF and not some other binary or text data mislabeled as PDF.
PDF files also end with the marker %%EOF on the last line. If you decode a Base64 PDF and the %%EOF marker is missing, the file is truncated — likely because the Base64 string itself was cut short during transfer. Our tool checks the header before offering a download; for end-of-file verification, you can use the bytes-summary output mode on our main decoder.
Encrypted vs Base64-encoded PDFs
People sometimes confuse two layers of obfuscation that PDFs can use. Base64 encoding is a transport wrapper — it converts binary bytes to printable ASCII so the PDF can travel through text-only channels. Anyone can decode it without a key. PDF encryption is a separate, content-level protection that requires a password (or certificate) to view. The two are independent.
It is entirely possible to have a Base64-encoded encrypted PDF — you decode the Base64 to get the binary PDF bytes, and then the PDF viewer prompts for a password. Our tool only handles the Base64 layer. To open password-protected PDFs, use a dedicated PDF viewer with the credentials.
How to view and verify your decoded PDF
After decoding, this tool offers two paths. Open in new tab creates a blob URL pointing to the decoded bytes and opens it in your browser's built-in PDF viewer. The blob URL is local — the PDF never touches a server, and the URL becomes invalid as soon as you close the tab. Download saves the decoded bytes as a regular .pdf file on your computer, suitable for opening in Adobe Reader, Preview, Foxit, or any other PDF application.
If the in-browser preview shows a blank document or "failed to load" message, the bytes likely do not form a valid PDF. Common causes: the Base64 string was truncated (check that it ends with multiple = characters or the bytes-summary mode shows close to the expected length), the Base64 had whitespace that was not properly stripped, or the original file was something other than a PDF.