Drop a PDF and copy the Base64 string in the shape your code needs: raw text, a data URL, a JSON attachment, an HTML iframe, or a MIME email part. The file is read in your browser and never reaches Toolexe.
The page checks the real bytes, not the file extension. A renamed Word file gets rejected. Page count comes from the PDF page tree, and files saved with compressed object streams hide the count, so the row says so instead of guessing.
Plain Base64 text with no prefix. REST APIs, database fields, and environment variables expect this one.
JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4K Your encoded PDF shows up here. Every valid PDF starts with JVBERi0.
Every Data URL from this converter has five parts. Knowing them lets you spot a broken string by eye, before a decoder throws a vague error at you.
data:schemeapplication/pdfmedia type;base64encoding flag,separatorJVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9UeXBlL0NhdGFsb2c...the PDF bytesThe payload of a valid PDF always opens with JVBERi0. Those seven characters are the bytes %PDF- run through Base64, and the PDF format requires every file to start with them. A string opening with anything else came from a different file type, or picked up a stray quote mark or byte order mark at the front.
One exception: some older PDF writers put a few junk bytes before the header, and Adobe Reader tolerates up to 1,024 of them. The inspector above accepts the same window and flags the offset, since a strict decoder on the other end might not.
The encoding is identical in every tab. What changes is the wrapper around the string, and the wrong wrapper is the most common reason an API rejects a perfectly good PDF.
| Destination | Tab and settings | Watch for |
|---|---|---|
| JSON body of a REST API call | JSON attachment, or Raw Base64 with no breaks | No escaping needed. The Base64 alphabet has no quotes or backslashes. Strip the data: prefix if you copied a Data URL by mistake. |
| Raw email with an attachment | MIME part | Lines stay at 76 characters. Some mail servers reject longer lines, and RFC 5322 caps any line at 998. |
| Inline preview on a web page | HTML iframe or Data URL | A data URL in a plain link opens a blank tab. Chrome, Firefox, and Edge block top-level navigation to data: URLs. |
| URL query string or path | Raw Base64, URL-safe on | The decoder needs the URL-safe alphabet from RFC 4648 section 5. A standard decoder chokes on - and _. |
| PEM-style config or legacy tooling | Raw Base64, 64-character lines | Remove the line breaks again before the same string goes into JSON. |
| Environment variable or secret store | Raw Base64, no breaks | Most .env parsers stop reading at the first newline. Kubernetes Secrets want standard Base64 in the data field. |
Base64 turns every 3 bytes into 4 characters. For a file of n bytes the encoded length is:
4 × ⌈n ÷ 3⌉
The result is a flat 33.3 percent increase, plus up to two = padding characters. Line breaks cost extra. MIME wrapping at 76 characters adds a CRLF pair per line, another 2.6 percent. The rows below show the largest PDF each common ceiling accepts.
| PDF size | Base64 length | Where the line falls |
|---|---|---|
| 200 KB | 273,068 chars (266.7 KB) | A one-page invoice or receipt. Fits anywhere, including a single database row. |
| 1 MB | 1,398,104 chars (1.33 MB) | Still comfortable for an API body. Pasting a string this long into some code editors starts to lag. |
| 4.5 MB | 6,291,456 chars (6.00 MB) | Exactly the AWS Lambda synchronous payload ceiling, before the JSON around the string. |
| 7.5 MB | 10,485,760 chars (10.00 MB) | Exactly the Amazon API Gateway REST payload ceiling. |
| 18.75 MB | 26,214,400 chars (25.00 MB) | The Gmail message ceiling, with zero room left for body text or headers. |
The fit meter in the converter uses these figures against the length of the active tab. Treat a Tight fit as over the line. Request headers, JSON keys, and the email body all count toward the same cap.
Base64 solves one problem: moving binary data through a channel built for text. Outside this one job, the extra third in size buys you nothing.
A text column holds a third more data than a binary column for the same file, and every query selecting the row drags the whole document along. Put the PDF in object storage and keep the URL in the row.
multipart/form-data sends the raw bytes. Encoding first wastes 33 percent of the upload, and the server has to decode before saving.
Base64 is an encoding, not encryption. Anyone holding the string gets the PDF back with one command. Only a file the Password row marks as Encrypted stays locked after decoding.
This page stops at 40 MB, since a 53 MB string slows copy and paste in most tabs. Use the terminal: base64 -w 0 report.pdf > report.b64 on Linux, base64 -i report.pdf -o report.b64 on macOS.
Test the round trip before wiring the string into production. Each snippet below writes the original bytes back to disk or opens them in a viewer. For a quick check without code, paste the string into the Base64 to PDF converter.
const bytes = Uint8Array.from(atob(b64), c => c.charCodeAt(0));
const blob = new Blob([bytes], { type: 'application/pdf' });
window.open(URL.createObjectURL(blob));
import base64
with open("invoice.pdf", "wb") as f:
f.write(base64.b64decode(b64, validate=True))
$bytes = base64_decode($b64, true);
if ($bytes === false) {
throw new RuntimeException('Not valid Base64');
}
file_put_contents('invoice.pdf', $bytes);
base64 --decode invoice.b64 > invoice.pdf head -c 8 invoice.pdf # prints %PDF-1.x
Strings made with the URL-safe option need - and _ turned back into + and / first. Python's base64.urlsafe_b64decode reads the URL-safe alphabet directly, though you still have to put the = padding back. Strict mode in PHP and validate=True in Python both reject a string with a data: prefix still attached.
Short answers on privacy, size, prefixes, and protected files.
Every PDF begins with the bytes %PDF-, and those five bytes encode to JVBERi0 in Base64. Seeing JVBERi0 at the start is a fast sign the string holds a PDF. A string starting with iVBORw0 is a PNG, and UEsDB is a ZIP or a DOCX.
No. The browser reads the file through the File API and the JavaScript on this page encodes the bytes on your device. Toolexe never receives the PDF or the string. Closing the tab discards both.
Only for browser attributes such as an iframe src. APIs, databases, and the JSON tab expect raw Base64. Sending the prefix to an API is a common cause of invalid Base64 errors, since the colon and semicolon sit outside the Base64 alphabet.
40 MB. A bigger file produces a string over 53 MB, which slows copying and pasting in most browser tabs. Use base64 -w 0 on Linux or base64 -i on macOS for anything larger.
Neither. Decoding returns the exact bytes you started with. The string is about 33 percent larger than the file, so shrink the PDF with a compressor first if size is the problem.
PDF 1.5 and later allow the page tree to sit inside compressed object streams. Reading the count would mean decompressing those streams, which this page skips to stay fast. The PDF itself is fine, and the Base64 output is unaffected.
Yes. The encrypted bytes encode like any others, and the decoded file still asks for the password. The Password row shows Encrypted when the file carries an Encrypt entry in its trailer.