Hero Background

Next-Gen App & Browser Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

PDF to Base64 Converter - TestMu AI (Formerly LambdaTest)

Encode any PDF to Base64, Data URI, or HTML embed in your browser. 100% client-side — your PDF never leaves your device.

Upload PDF

Output Format

Base64 Output

What is PDF to Base64?

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.

How to Convert a PDF to Base64 Online

  • Upload your PDF. Drag and drop a .pdf file onto the upload area, or click to browse. The file name and size appear once the PDF is selected.
  • Pick an output format. Choose Plain Base64, Data URI, or HTML <embed> from the format dropdown. The output updates instantly without re-reading the file.
  • Copy or download. Copy the Base64 string to your clipboard or download it as a .txt file. The Base64 string is always the full PDF — even when the preview textarea truncates long outputs for display.
  • Verify the preview. On desktop browsers, the live preview renders the encoded PDF using its Data URI so you can visually confirm the result is valid. On iOS, an Open in new tab fallback is shown instead.

Output Formats Explained

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" />

Common Use Cases

  • JSON / REST API payloads: e-signature services (DocuSign, HelloSign), payment processors (Stripe Files, Plaid), and document APIs commonly accept PDFs as Base64 strings inside JSON bodies.
  • Email attachments via API: SendGrid, Mailgun, Postmark, and Amazon SES all let you attach a PDF by passing its Base64 representation in the request body.
  • Embedding PDFs in HTML: drop a Data URI into an <embed>, <iframe>, or <object> to render the document inline without hosting it.
  • Database storage: legacy systems that store binary content in TEXT or VARCHAR columns rely on Base64 to keep bytes safe across SQL transport.
  • Mobile bridges: React Native, Cordova, and Capacitor often pass PDFs across the JS/native bridge as Base64 because raw ArrayBuffers are awkward over the wire.
  • API testing: craft a Postman, Insomnia, or curl request body that includes a real PDF without juggling multipart form data.

Why Convert PDFs to Base64?

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.

How Our Tool Keeps Your PDF Private

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.

PDF to Base64 vs. Base64 to PDF

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.

Limitations and Tips

  • Size inflation: the Base64 string will be ~33% larger than the original PDF. Plan API payload limits accordingly.
  • Mobile memory: encoding very large PDFs (above ~50 MB) on mobile browsers can run out of memory and crash the tab. Consider compressing the PDF first.
  • iOS Safari preview: iOS Safari does not render Data-URI PDFs inline. The tool detects iOS and offers an Open in new tab fallback automatically.
  • Source control hygiene: avoid checking long Base64 strings into Git diffs. Store them in a fixtures file or reference an external resource instead.
  • Encoding is not encryption: Base64 is fully reversible. Don't treat it as a security measure for sensitive PDFs — encrypt the file separately if needed.

Frequently Asked Questions (FAQs)

What is a PDF to Base64 converter?

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.

How do I convert a PDF file to a Base64 string?

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.

Is this PDF to Base64 tool free?

Yes. The PDF to Base64 converter is 100% free, with no sign-up, no watermarks, no daily quotas, and no software installation required.

Is my PDF uploaded to a server?

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.

What's the maximum PDF file size I can convert?

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.

Why does the Base64 string look about 33% larger than my PDF?

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.

What is the difference between a plain Base64 string and a Data URI?

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.

How do I embed a PDF in HTML using Base64?

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.

How do I use a PDF Base64 string in a JSON API request?

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.

How do I convert a Base64 string back to a PDF?

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.

Does Base64 encoding compress or encrypt my 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.

Why is my PDF preview not displaying after encoding?

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.

Can I convert password-protected PDFs to Base64?

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.

Will my PDF metadata be preserved?

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

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests