data:application/pdf;base64,…, JSON object, or HTML embed tag.
data:application/pdf;base64,…, JSON object, or HTML embed tag.
Decoding a Base64 string back to a PDF is simple in theory — but real-world inputs come wrapped in data URIs, embedded in JSON API responses, or pulled from HTML markup. This tool handles all those formats automatically, verifies the result is actually a PDF, and lets you preview it before downloading — all without leaving your browser.
data:application/pdf;base64,…, JSON object, or HTML <embed> tag. The tool identifies the format automatically and extracts the raw Base64 without any manual cleanup.%PDF- magic header in the first bytes of the output. If the header is present, the file is confirmed as a genuine PDF. If not, a warning is shown so you know the Base64 encoded a different file type..pdf extension is added automatically..txt, .b64, or .json file onto the upload zone and its content is loaded into the input automatically. Useful when the Base64 string is very large or stored in a file.The whole process takes under a minute. Here's how to go from a Base64 string to a downloaded PDF.
Base64-encoded PDFs appear in many places in modern software. Understanding where they come from helps you decode them reliably.
PDFs are binary files — they contain bytes that can't be safely transmitted in text-only channels. REST APIs commonly return PDFs as Base64 strings inside JSON responses (e.g. "pdf": "JVBERi0x…"). MIME email attachments encode PDFs as Base64 in the message body. HTML embeds use the data URI format (data:application/pdf;base64,…) to inline a PDF without a separate file request. Database storage sometimes stores file blobs as Base64 text in VARCHAR or TEXT columns. Webhook payloads and cloud storage exports (AWS S3 presigned content, Google Drive API export) can also return PDFs in Base64. This tool handles all of these formats — just paste and decode.
The decoding process has four steps. 1. Format detection: the tool scans for known wrappers — a base64, marker (data URI), a { opening brace (JSON), or falls back to treating the whole input as raw Base64. 2. Sanitisation: non-Base64 characters (whitespace, URL-safe substitutions, smart quotes from copy-paste) are stripped and corrected, and padding (=) is recalculated. 3. Decoding: the browser's native atob() function converts Base64 to a binary string, which is then written into a Uint8Array. 4. Verification: the first 5 bytes are checked for the PDF magic number %PDF-. If present, a Blob URL is created for download and preview. No server involvement at any step.
"Could not extract a valid Base64 string" — the input is empty or contains only non-Base64 characters. Check that you copied the full string, including any trailing = padding. "Base64 decode failed" — the string is corrupt or truncated. Re-copy it from the source, ensuring nothing was cut off. "Not a PDF" — the Base64 decodes successfully but the result is not a PDF — it may be a PNG, JPEG, ZIP, or other file type. Use the general Base64 decoder instead to reconstruct the correct file type. Garbled or extra characters — some copy-paste operations add smart quotes, non-breaking spaces, or soft hyphens around the Base64 string; this tool's sanitiser handles these automatically. If you still get errors, try enabling "Strip whitespace & newlines" in the Options panel.
From developers debugging API responses to accounts teams recovering invoices from email raw source, this tool fits wherever a PDF arrives as Base64 text.
All of the following input formats are auto-detected and handled correctly. No manual pre-processing needed.
| Format | Example | Where You Find It |
|---|---|---|
| Raw Base64 | JVBERi0xLjQg… | API responses, clipboard exports, .b64 files |
| Data URI | data:application/pdf;base64,JVBERi0x… | HTML embeds, CSS, direct API payloads |
| JSON object | {"pdf":"JVBERi0x…"} or any key name | REST APIs, webhook payloads, ERP exports |
| HTML embed tag | <embed src="data:application/pdf;base64,…"/> | HTML email, web app source code |
| .txt / .b64 file | File containing raw Base64 or data URI text | Exported files from encoders, scripts |
| URL-safe Base64 | JVBERi0x… with - and _ instead of + and / | JWT-adjacent tooling, some API SDKs |
Answers to the most common questions about decoding Base64 to PDF.
Paste your Base64 string into the text area and click "Decode to PDF". The tool handles all formats — raw Base64, data URIs, JSON objects, and HTML embed tags. After decoding, click Download PDF to save the file.
The Base64 decoded successfully but the resulting binary doesn't start with %PDF-. The original file was probably an image, ZIP, or other type — not a PDF. You can still download it. For non-PDF files, use the Base64 Encode/Decode tool's "Decode to File" mode with the correct file extension.
You can paste the entire JSON object — no need to extract the Base64 manually. The tool parses it and tries each string value until it finds one that decodes to a valid binary. For example, paste {"invoice":"JVBERi0x…","status":"ok"} directly and it will find and decode the PDF value.
Yes. All decoding runs in your browser via JavaScript. No data is transmitted to any server. The tool works entirely offline after the page loads. Your Base64 string and the decoded PDF are never logged, stored, or shared anywhere.
Yes. After decoding, click Show Preview to render the PDF in-page using PDF.js. Use the Prev/Next buttons to navigate multi-page PDFs. Enable "Auto-show preview on decode" in the Options panel to have it appear automatically every time.
Use the PDF to Base64 tool at tools.i7pixel.com/pdf-to-base64 to go in the opposite direction — upload a PDF file and get its Base64 string, data URI, or HTML embed code.
Tried the tool? Leave a quick rating and help others find it.
All tools at I7 Pixel run in your browser — no uploads, no accounts, always free.