Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Encode any PDF to Base64, Data URI, or HTML embed in your browser. 100% client-side — your PDF never leaves your device.
The PDF to Base64 Converter by TestMu AI is a free online tool that encodes any PDF file into a Base64 text string directly in your browser. Base64 is a binary-to-text encoding that represents arbitrary bytes using a 64-character alphabet (A–Z, a–z, 0–9, +, /), and it's the universal way to carry binary payloads safely through text-only channels like JSON, XML, HTML, and email.
Once you drop a PDF onto the tool, it instantly returns three ready-to-use formats: the raw Base64 string, a full data:application/pdf;base64,… Data URI, and an HTML <embed> tag you can paste straight into a page. Everything runs locally — there is no upload, no server, no log, no quota.
.pdf file onto the upload area, or click to browse. The file name and size appear once the PDF is selected.<embed> from the format dropdown. The output updates instantly without re-reading the file..txt file. The Base64 string is always the full PDF — even when the preview textarea truncates long outputs for display.Plain Base64 — the raw encoded string with no prefix. Use this when you need to drop the payload into a JSON or XML field, store it in a database column, or pass it to a function that expects just the encoded bytes.
JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9MZW5ndGggMTU3IC9GaWx0ZXIgL0ZsYXRlRGVjb2RlPj4Kc3RyZWFt...Data URI — the encoded string prefixed with the MIME marker. Pasteable directly into HTML attributes, used by browsers and parsers to recognise the content type.
data:application/pdf;base64,JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9MZW5n...HTML <embed> — a complete tag with the Data URI as the src. Paste it into any HTML page to render the PDF inline.
<embed src="data:application/pdf;base64,JVBERi0xLjQK..." type="application/pdf" width="100%" height="600px" /><embed>, <iframe>, or <object> to render the document inline without hosting it.TEXT or VARCHAR columns rely on Base64 to keep bytes safe across SQL transport.ArrayBuffers are awkward over the wire.Base64 is the lingua franca for moving binary data through text-only channels. JSON, XML, YAML, email bodies, HTML attributes, query strings, and most config formats all accept text but reject raw bytes. Encoding a PDF as Base64 keeps the file intact while letting it travel inside any of those containers.
It also makes the PDF self-contained. Once the document is inside a JSON document or an HTML page, there is no separate file to upload, no URL to host, no expiry to track, and no CORS rules to fight. The trade-off is a ~33% size increase and that long Base64 strings can be unwieldy in source control — both reasonable costs for the portability you get.
Most PDF to Base64 tools online upload your file to a server, encode it there, and return the string. That's fine for marketing PDFs but a real problem for contracts, medical records, HR documents, or anything that should not leave your machine.
This tool is different. It uses the browser's FileReader.readAsDataURL() API to read the PDF locally and encode it inline. The file bytes never touch a network socket. We do not have a backend that could see your PDF even if we wanted to. You can open the browser DevTools Network tab while encoding to confirm: there are no upload requests.
This converter only handles the forward direction — file in, string out. To decode a Base64 string back into a binary file, use a generic Base64 decoder or paste the full Data URI into a browser address bar to view it as a PDF directly.
You may also be interested in our related encoders: File to Base64 (generic file encoder), Image to Base64, and Base64 to Image for the image direction.
A PDF to Base64 converter encodes a binary PDF file into a Base64 text string so it can be safely embedded inside text-only contexts such as JSON payloads, HTML, CSS, XML, or email bodies. The output represents the exact same PDF as ASCII characters instead of raw bytes.
Drag and drop your PDF onto the upload area (or click to browse). The tool encodes it instantly in your browser. Choose Plain Base64, Data URI, or HTML <embed> from the output format selector, then copy the result or download it as a .txt file.
Yes. The PDF to Base64 converter is 100% free, with no sign-up, no watermarks, no daily quotas, and no software installation required.
No. All encoding happens locally in your browser using the FileReader API. Your PDF never leaves your device, is never uploaded, and is never stored or logged. That makes the tool safe for confidential contracts, legal documents, medical PDFs, and any other sensitive files.
There is no artificial size cap. The practical limit is your browser's memory. Files above ~50 MB will show a warning since Base64 strings inflate by about 33% and can become unwieldy in mobile browsers.
Base64 encodes every 3 bytes of binary data as 4 ASCII characters, which inflates the size by roughly 33% (4/3). This is inherent to the encoding — it's not compression. If you need a smaller payload, compress the PDF before encoding or use a binary transport instead.
A plain Base64 string is just the encoded payload. A Data URI prepends the MIME type and encoding marker, so the full string looks like data:application/pdf;base64,JVBERi0xLjQK… and can be used directly in HTML <embed>, <iframe>, <object>, <a href> or as an image source.
Select the HTML <embed> output format from the dropdown and copy the result. It produces a ready-to-paste tag of the form <embed src="data:application/pdf;base64,…" type="application/pdf" width="100%" height="600px" />. You can also use <iframe> or <object> with the same Data URI.
Pick the Plain Base64 output, then assign it to a string field in your JSON body, for example {"filename":"invoice.pdf","mimetype":"application/pdf","data":"JVBERi0xLjQK…"}. Most e-sign, payment, and document APIs (DocuSign, Stripe Files, SendGrid attachments, etc.) accept this shape.
You can decode the string back to bytes in any language (atob in JavaScript, base64.b64decode in Python, Convert.FromBase64String in C#) and write the result to a .pdf file. You can also paste a Data URI directly into a browser address bar to view the PDF.
No. Base64 is purely a representation change — bytes become ASCII characters. It does not compress (it actually grows the payload by ~33%) and it does not encrypt or obfuscate the content in any meaningful way. Anyone with the Base64 string can decode it back to the original PDF.
Inline PDF preview relies on the browser's native PDF viewer. iOS Safari and some mobile browsers block Data-URI PDFs in <embed>; the tool detects this and offers an Open in new tab fallback. On very large PDFs the preview can also be slow to render — try the download button to verify the file instead.
Yes. Base64 encoding doesn't open, parse, or decrypt the PDF — it just encodes the raw bytes. A password-protected PDF will encode just fine, and the decoded result will still require the same password to view.
Yes. Base64 is a lossless byte-for-byte encoding, so every part of the PDF — text, images, fonts, embedded files, signatures, and metadata — is preserved exactly. Decoding the string produces a file identical to the original.
Did you find this page helpful?
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance