Paste Base64 or a PDF data URI — preview and download. Processing stays in your browser — nothing is uploaded.
Two patterns identify a Base64 PDF at a glance:
JVBERi0x…
data:application/pdf;base64,JVBERi0x…
Nearly every decode failure comes from one of four causes. Here is how to diagnose and fix each one.
Cause: Base64 output length must be a multiple of 4 characters. When the source byte count is not divisible by 3, one or two = padding characters are appended. Some systems strip padding when storing or transmitting Base64. A string of length 4n+1 is always invalid; 4n+2 needs == appended; 4n+3 needs = appended.
Fix: Add the missing = characters to the end of the string until its length is a multiple of 4, then paste again. Most decoders (including this one) handle missing padding automatically, but some pipelines produce truncated strings that need manual repair.
JVBERi0xLjQKJcfs4AAQ
JVBERi0xLjQKJcfs4AAQ==
Cause: MIME Base64 (RFC 2045) inserts a line break every 76 characters for email compatibility. When you copy a Base64 PDF from email source, a multipart body, or some APIs, the string contains embedded newlines (\n or \r\n). Standard Base64 (RFC 4648) does not allow whitespace.
Fix: This tool strips whitespace automatically before decoding. If you are decoding in code, remove whitespace first: b64.replace(/\s/g, "") in JavaScript, or b64.strip() in Python.
JVBERi0xLjQK Jcfs4AAQ== WVBERi0x...
JVBERi0xLjQKJcfs4AAQ==WVBERi0x...
Cause: RFC 4648 defines two Base64 variants. Standard Base64 uses + and / as the 62nd and 63rd characters. URL-safe Base64 (Base64url) replaces these with - and _ to avoid conflicts in URLs and JSON Web Tokens. If your string contains - or _, it is URL-safe and needs conversion before standard decoding.
Fix: Replace all - with + and all _ with / before pasting, then add padding if needed. In code: b64.replace(/-/g, "+").replace(/_/g, "/").
JVBERi0xLjQKJcfs-AAQ_Wg==
JVBERi0xLjQKJcfs+AAQ/Wg==
Cause: Large Base64 strings are often truncated when copied from log viewers, API explorers, or terminal output that cap display length. A PDF that is 1MB will encode to approximately 1.4 million Base64 characters — easy to accidentally copy only part of.
Fix: Copy the full Base64 value programmatically rather than from a display. In curl output, redirect to a file. In API explorers, use the raw response view and copy the entire field value.
JVBERi0xLjQK... [truncated in log viewer]
// Fetch the full value programmatically:
const response = await fetch("/api/generate-pdf")
const { pdf } = await response.json()
// pdf is the complete Base64 stringUse this tool to verify a Base64 string visually. When you are ready to handle decoding in your own application, here are the standard approaches.
// Decode Base64 PDF and save to disk
const fs = require('fs')
const base64String = 'JVBERi0xLjQ...' // your Base64 string
const buffer = Buffer.from(base64String, 'base64')
fs.writeFileSync('output.pdf', buffer)
// Or decode a data URI:
const dataUri = 'data:application/pdf;base64,JVBERi0xLjQ...'
const raw = dataUri.split(',')[1]
const buf = Buffer.from(raw, 'base64')
fs.writeFileSync('output.pdf', buf)import base64
base64_string = 'JVBERi0xLjQ...' # your Base64 string
# Add padding if needed
padding = 4 - len(base64_string) % 4
if padding != 4:
base64_string += '=' * padding
pdf_bytes = base64.b64decode(base64_string)
with open('output.pdf', 'wb') as f:
f.write(pdf_bytes)<?php
$base64String = 'JVBERi0xLjQ...'; // your Base64 string
$pdfBytes = base64_decode($base64String);
file_put_contents('output.pdf', $pdfBytes);
// Verify it is a real PDF
if (substr($pdfBytes, 0, 4) !== '%PDF') {
throw new Exception('Decoded data is not a valid PDF');
}No. Decoding runs entirely in your browser using JavaScript. The Base64 string you paste is processed in memory and never transmitted over the network. The PDF preview uses a local blob URL created by your browser — no file is uploaded or stored anywhere.
A Base64-encoded PDF always starts with JVBERi0 — this is the Base64 encoding of %PDF, the magic header required by every valid PDF file. If your string starts with data:application/pdf;base64, it is a PDF data URI and you can paste it directly. If neither pattern matches, the string is either not a PDF or was encoded with a different method.
This error means the decoded bytes do not begin with %PDF. Common causes: (1) the string is URL-safe Base64 using - and _ instead of + and / — replace them before pasting; (2) the string is truncated — only part of the PDF was copied; (3) the original file is not a PDF — it may be a Word document, image, or other binary file that was incorrectly assumed to be a PDF.
In-browser PDF preview uses a blob URL and your browser's built-in PDF viewer. Safari on iOS does not support inline PDF rendering via blob URLs — use the Download button instead and open the file in Files or a PDF app. Some corporate browsers with strict Content Security Policies may also block blob URLs. In both cases, the download still works.
Base64 encodes 3 bytes at a time into 4 characters. When the input length is not divisible by 3, padding characters (=) are appended to make the output length a multiple of 4. A string ending in = has 1 padding character (2 remaining input bytes); == has 2 (1 remaining byte). Many systems strip padding when storing Base64. If your string length modulo 4 is 2, add ==; if it is 3, add =. This tool handles missing padding automatically.
A plain Base64 string is just the encoded bytes — for example JVBERi0xLjQ.... A data URI wraps the Base64 with a MIME type prefix: data:application/pdf;base64,JVBERi0xLjQ.... Data URIs are used in HTML src attributes and browser JavaScript. APIs and most backend systems use plain Base64. This tool accepts both — it automatically detects and strips the data URI prefix if present.
Yes, but you need to convert it first. URL-safe Base64 (RFC 4648 Section 5) replaces + with - and / with _. This variant is used in JSON Web Tokens (JWT), URL parameters, and some file storage APIs. Replace all - with + and all _ with / in your string, add any missing = padding, then paste the result into this tool.
This usually means the Base64 string was truncated — only part of the PDF was decoded. PDFs are structured binary files and a partial decode produces a syntactically invalid file that browsers render as blank. Verify the full Base64 string length is correct: a 1MB PDF encodes to approximately 1,398,101 characters. If the string is shorter than expected, fetch the complete value programmatically rather than copying from a display.