Free PDF to Base64 Converter & Decoder

Encode a PDF to Base64 or a data:application/pdf URI, or paste Base64 to decode, preview the pages and download the PDF. Works offline in your browser.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideHow to Embed a PDF as Base64 in JSON, HTML or an API Request →

About the PDF to Base64 tool

Developers regularly need a PDF as Base64 text: to embed it in a JSON API request, store it in a database field, send it through an email or webhook payload, put it in a test fixture, or display it with a data: URI. Going the other way is just as common, when an API response hands you a long Base64 string and you need to see the actual document.

The "PDF → Base64" tab reads your file locally and encodes it with the browser's native encoder, which handles files of tens of megabytes quickly. Optionally add the data:application/pdf;base64, prefix, or wrap lines at 76 characters as MIME email bodies expect. Large outputs are shown truncated in the text box to keep the page responsive, but Copy and Download always include the full string.

The "Base64 → PDF" tab accepts plain Base64, URL-safe Base64 (with - and _), strings with line breaks or missing padding, and complete data URIs. It checks that the decoded bytes really are a PDF by looking for the %PDF- header, renders thumbnails of the pages with pdf.js so you can confirm the content, and lets you download the file. Nothing is sent to a server.

How to use PDF to Base64

  1. To encode, stay on "PDF → Base64" and drop your PDF file.
  2. Toggle the data URI prefix or 76-character line wrapping if required.
  3. Click "Copy Base64" or "Download .txt".
  4. To decode, open "Base64 → PDF" and paste the Base64 string or data URI.
  5. Check the page thumbnails and click "Download PDF".

Features

Two-way conversion

Encode PDF to Base64 and decode Base64 back to a PDF in one tool.

Data URI and MIME options

Add the data:application/pdf;base64 prefix or wrap lines at 76 characters.

Forgiving decoder

Accepts whitespace, URL-safe characters, missing padding and full data URIs.

PDF validation and preview

Confirms the %PDF- header and shows page thumbnails of the decoded file.

Handles large files

Uses native browser encoding; the full string is always available to copy or download.

When to use it

  • Embed a PDF in a JSON payload for a REST API or webhook.
  • Inspect a Base64 PDF returned by an e-signature, invoicing or shipping-label API.
  • Create test fixtures or mock responses containing PDF documents.
  • Build a data: URI to show a small PDF inline in an HTML page.
  • Recover a PDF attachment from a raw email source or log file.

Frequently asked questions

How much bigger is Base64 than the original PDF?

About 33% bigger, because every 3 bytes become 4 text characters. Line wrapping and the data URI prefix add a little more.

What is a PDF data URI?

A string that starts with data:application/pdf;base64, followed by the Base64 data. It lets you reference the PDF inline, for example in an iframe or link, without a separate file.

Why does decoding say my text is not a PDF?

The Base64 decoded correctly, but the result doesn't begin with the %PDF- signature. It may be a different file type, a truncated string, or Base64 that was encoded twice.

Can I decode URL-safe Base64?

Yes. The - and _ characters are converted to + and / automatically, and missing = padding is added.

Is my PDF or Base64 data uploaded?

No. Encoding, decoding and previews all happen locally in your browser.

Related tools