PDF to Base64 Converter

Encode a PDF document as Base64 for API requests, email or HTML embedding. A built-in viewer shows the PDF, so you can confirm it is the right file before you copy the result.

Runs entirely in your browser. Nothing is uploaded.

How to use

  1. Drop a PDF onto the upload area or click to choose one (up to 100 MB).
  2. Look at the preview to make sure it is the right document.
  3. Choose raw Base64 for API requests, or a data URI to embed the PDF in a web page.
  4. Copy the result or download it as a .txt file.

Sending PDFs through JSON APIs

JSON has no binary type, so REST APIs that receive documents usually take them as a Base64 string. E-signature platforms, invoicing and e-billing systems, print and mail services, OCR engines and document archives commonly accept PDFs this way, in a field such as content, file or documentBase64, with the file name in a separate field. Some services return PDFs the same way; Base64 to PDF turns those back into files.

Send raw Base64 without line breaks unless the API documentation says otherwise, since many APIs reject a value that still carries the data:application/pdf;base64, prefix. Keep request size limits in mind too: a 7.5 MB PDF becomes about 10 MB of Base64.

Recognizing a Base64 PDF

A PDF file begins with the characters %PDF- followed by the version number. Encoded as Base64, those bytes always give a string starting with JVBERi0. A long string starting with JVBER in an API response, a database column or a log file is almost certainly a PDF. The same check works before you send a payload: if your string starts with anything else, you may have encoded the wrong data, or encoded it twice.

Embedding a PDF in HTML

A data URI places the whole PDF inside an HTML page, with no separate file to host:

<embed src="data:application/pdf;base64,JVBERi0..." type="application/pdf" width="100%" height="600">

<iframe src="data:application/pdf;base64,JVBERi0..." width="100%" height="600"></iframe>

This works in desktop browsers with a built-in PDF viewer, but it has limits. Many mobile browsers do not display PDFs inside a page at all. Chrome and some other browsers also block a page from sending the whole tab to a data: URL, so a link or a window.open call pointing at a data:application/pdf URI may open a blank tab or do nothing. To open a PDF in a new tab from JavaScript, convert the Base64 to a Blob URL instead. For documents larger than a few megabytes, a normal file URL is usually the better choice.

Encoding a PDF in code

# Python: build a JSON request body
import base64, json
from pathlib import Path

pdf_b64 = base64.b64encode(Path('invoice.pdf').read_bytes()).decode('ascii')
body = json.dumps({'filename': 'invoice.pdf', 'content': pdf_b64})

// Browser: file comes from an <input type="file">
const reader = new FileReader();
reader.onload = () => {
  const pdfBase64 = reader.result.split(',')[1]; // drop the data URI prefix
};
reader.readAsDataURL(file);

Frequently asked questions

Why does my PDF Base64 string start with JVBERi0?
Those characters are the Base64 encoding of %PDF-, the header at the start of every PDF file. Seeing them confirms that the string contains a PDF.
Is the PDF uploaded when I convert it?

No. The file is read, encoded and previewed locally in your browser. Contracts, invoices and other confidential documents never leave your device.

Does encoding change or compress the PDF?

No. The Base64 string decodes to exactly the same bytes, so password protection, digital signatures, form fields and metadata are all preserved. The text is about 33% larger than the PDF; to reduce the size, compress the PDF before encoding it.

Should I turn on line wrapping?

Only when the format requires it, for example when you build a MIME email by hand, where attachment lines are limited to 76 characters. JSON APIs and HTML data URIs expect one continuous string.

How large can the PDF be?

The tool accepts files up to 100 MB. For APIs the practical limit is usually lower, so check the maximum request size and remember that Base64 adds about a third. Very long output can be slow to show on screen; use Download for large documents.