Convert a PDF to Base64, data URI, HTML embed, or JSON. Processing stays entirely in your browser — nothing is uploaded.
Drop a PDF here or choose a file
Six output formats are available. Choosing the wrong one is the most common source of confusion — a data URI that works perfectly in an HTML attribute will be rejected by most APIs.
Use when: Sending a PDF payload to an API, storing in a database TEXT/BLOB column, or passing to a language's Base64 decode function.
JVBERi0xLjQKJcfs...
Use when: Setting the src attribute in JavaScript, embedding in a CSS background, or passing directly to window.open() to display the PDF in a new tab.
data:application/pdf;base64,JVBERi0x…
Use when: Inline PDF viewer in an HTML page. Renders using the browser's built-in PDF plugin. Works in Chrome and Firefox; Safari on iOS does not support PDF embed.
<embed src="data:application/pdf;base64,…" type="application/pdf" width="100%" height="600px" />
Use when: Triggering a browser download from a button or link — no server required. The download attribute sets the suggested filename. Works across all modern browsers.
<a href="data:application/pdf;base64,…" download="report.pdf">Download PDF</a>
Use when: Embedded PDF viewer with a fallback message for browsers that cannot display it. More standards-compliant than embed; preferred when accessibility and graceful degradation matter.
<object data="data:application/pdf;base64,…" type="application/pdf">PDF cannot be displayed.</object>
Use when: REST API payloads, webhooks, or structured storage. The JSON output includes fileName, mimeType, encoding, raw base64, and the full data URI — ready to include in a request body.
{ "fileName": "doc.pdf", "mimeType": "application/pdf", "encoding": "base64", "base64": "JVBERi0x…" }PDF is a binary format. It contains raw bytes — many of which are control characters, null bytes, and values outside the printable ASCII range. When you try to embed binary data directly inside a text-based format (JSON, XML, HTML, or email), those binary bytes corrupt the structure.
A null byte inside a JSON string terminates the string early in some parsers. A byte with value 0x3C (<) inside XML is interpreted as a tag opening. An 0x0D byte (carriage return) in a MIME email body signals end-of-line. Binary data in text contexts causes silent data corruption.
Base64 solves this by converting every group of 3 binary bytes into 4 printable ASCII characters drawn from a safe 64-character alphabet: A–Z, a–z, 0–9, +, and /. The output contains no control characters, no null bytes, and no characters with special meaning in JSON, XML, HTML, or email — making any binary file safe to embed in any text protocol.
Base64 encoding always increases file size by exactly one-third. Every 3 bytes of binary data become 4 ASCII characters — a 33.3% overhead. This is a fundamental property of the encoding, not a tool limitation.
| Original PDF size | Encoded size | Practical implication |
|---|---|---|
| 100 KB | ~133 KB | Safe for data URIs, inline HTML, most APIs |
| 1 MB | ~1.33 MB | Fine for most APIs; slightly slow as inline data URI |
| 5 MB | ~6.7 MB | Approaching email attachment limits; check API limits |
| 10 MB | ~13.3 MB | Exceeds many API payload limits — use multipart upload instead |
| 25 MB | ~33.3 MB | Exceeds most email provider limits — use a file hosting URL |
For PDFs over 5MB, consider whether Base64 is the right approach. Multipart/form-data uploads, presigned S3 URLs, and file hosting services handle large binaries more efficiently than Base64-in-JSON.
Most errors with PDF Base64 encoding come from using the wrong output format or ignoring the size overhead.
// Sending the full data URI — wasteful and often rejected
{
"pdf": "data:application/pdf;base64,JVBERi0x…"
}// Send plain Base64 only — decode the prefix first
{
"pdf": "JVBERi0x…"
}The data URI prefix (data:application/pdf;base64,) is for browser consumption — HTML src attributes and JavaScript. Most APIs expect raw Base64 without the prefix and will either reject the request or misparse the field if you include it. Use the plain Base64 output format for API payloads.
// 10MB PDF file — assume API accepts up to 10MB JSON bodies
fetch("/api/upload", { body: JSON.stringify({ pdf: base64String }) })// 10MB PDF encodes to ~13.3MB — exceeds most API payload limits // Use multipart/form-data or a presigned URL for large files instead
Base64 encoding inflates file size by exactly 33% (every 3 bytes of binary become 4 ASCII characters). A 10MB PDF becomes ~13.3MB encoded. Most APIs, email servers, and HTTP proxies have payload size limits — commonly 10MB for APIs, 10–25MB for email. For large PDFs, upload directly via multipart/form-data or a presigned storage URL instead.
<!-- Breaks silently on Safari iOS — no PDF visible --> <embed src="data:application/pdf;base64,…" type="application/pdf" />
<!-- object tag with fallback link --> <object data="data:application/pdf;base64,…" type="application/pdf"> <a href="data:application/pdf;base64,…" download="doc.pdf">Download PDF</a> </object>
Safari on iOS does not support inline PDF rendering via <embed> or <object> with data URIs. Use the HTML object format which includes a fallback content block — users on iOS will see the fallback link and can still download the PDF. Chrome, Firefox, and desktop Safari render inline without issues.
// A Word .docx file renamed to report.pdf // The tool will reject it with "not a valid PDF" error
// Upload the actual PDF — the tool checks the %PDF magic header // Convert your document to PDF first using your OS print dialog
PDF files always begin with the bytes %PDF (hex: 25 50 44 46). This tool verifies the file's magic header, not just its name or extension. A file renamed to .pdf but originating from Word, Excel, or any other format will fail validation. Use your operating system's "Print → Save as PDF" to produce a genuine PDF first.
No. The entire encoding process runs in your browser using the FileReader API and JavaScript. Your PDF is read from your local file system, converted to Base64 in memory, and never transmitted over the network. You can disconnect from the internet after the page loads and the tool will continue to work.
A data URI is a URL that contains the file's content directly rather than pointing to an external location. For a PDF, it takes the form data:application/pdf;base64,<encoded-string>. Use it when you want to embed or link to a PDF without hosting the file on a server — in HTML src attributes, download links, or JavaScript. Avoid data URIs for large PDFs (over 2MB) as they can slow page parsing and are not cached by browsers the same way external URLs are.
Base64 encodes every 3 bytes of binary data into 4 ASCII characters. Since ASCII uses only 6 of the 8 available bits per character (64 characters = 2⁶), each 3-byte group (24 bits) maps to four 6-bit groups represented as 4 characters. This means 3 bytes in → 4 bytes out, a 33.3% increase. Padding characters (=) are added to make the output length a multiple of 4.
<embed> is simpler and widely supported in Chrome and Firefox. <object> is more standards-compliant, supports a fallback content block for browsers that cannot display the PDF, and is generally preferred when accessibility matters. On Safari iOS, neither renders inline — provide a download link as fallback. For most desktop web applications, <embed> is the practical choice; for broader compatibility, use <object> with a fallback.
There is no hard limit imposed by this tool — it is constrained by your browser's available memory. In practice, browsers handle files up to several hundred megabytes comfortably, though very large PDFs will produce extremely long Base64 strings. Note that a 10MB PDF encodes to ~13.3MB of text. If you plan to use the output in an API request or email, check the payload size limits of your target service before encoding large files.
Yes. The JSON output includes the fileName, mimeType, encoding, raw base64 string, and full data URI. You can use JSON.parse() on the output, extract the base64 field, and include it in a fetch POST body as part of your request JSON. Most document and email APIs expect the raw base64 field, not the full data URI — use the base64 field, not dataUrl.
A valid Base64-encoded PDF always starts with JVBERi0 — this is the Base64 encoding of the bytes %PDF (the PDF magic header required by ISO 32000, the PDF specification). If your encoded output starts with these characters, the source file is a genuine PDF. If not, the file may have been corrupted during encoding or was not a PDF to begin with.
The correct MIME type for PDF files is application/pdf, standardised by IANA. This is what this tool uses in all output formats — data URIs, HTML embed, and the JSON output. Some older systems use application/x-pdf or application/octet-stream, but application/pdf is the correct, universally supported value. Using the wrong MIME type can prevent browsers from rendering the PDF inline and may cause download dialogs to show incorrect file type information.