PDF to Base64 Converter – Free

Convert a PDF to Base64 without uploading it. Choose the file and get its contents as one standard Base64 string, ready for a JSON field, an XML element or an email part.

How to use the PDF to Base64 tool

  1. Select the File control and choose a PDF from your device. The file picker is filtered to PDF documents.
  2. Select Encode file. The browser reads the document into memory and encodes every byte.
  3. Read the Base64 text in the Result box. It is a single unbroken line with no data URL prefix.
  4. Select Copy to copy the string, or Download to save it as a text file named after the original with .base64 added.

How PDF to Base64 encoding works

A PDF is a binary file. Compressed page streams, embedded fonts and images use every possible byte value, and many of those bytes break formats that expect text, such as JSON strings, XML documents and email bodies. Base64, defined in RFC 4648, solves that by reading the file three bytes at a time and writing each 24-bit group as four characters from a 64-character alphabet. A final group of one or two bytes is completed with = padding.

This tool uses the standard alphabet with + and / and keeps the padding. Decoding the result gives back the same file, byte for byte.

A worked example: the PDF header

Every PDF starts with the marker %PDF- followed by a version number. Take a file whose first line is %PDF-1.7 and a line feed. Those nine bytes form three complete groups, so they encode to twelve characters with no padding.

The marker is why a Base64 PDF is easy to spot. The five bytes of %PDF- always produce JVBERi, and for versions 1.x and 2.x the next character is 0. If an unknown string begins with JVBERi0, it is almost certainly a PDF.

Header text:   %PDF-1.7 + line feed
Header bytes:  25 50 44 46 2d 31 2e 37 0a
Base64:        JVBERi0xLjcK

Limits and what the tool does not check

The limits below come straight from the code that runs on this page.

  • Maximum size is 20 MiB, which is 20,971,520 bytes. A larger file stops with the message Choose a file up to 20 MiB. A file at the limit yields 27,962,028 Base64 characters.
  • The PDF filter applies to the file picker only. The bytes are not inspected, so a file of another type chosen through the picker is encoded as well.
  • Encrypted, password-protected, scanned and damaged PDFs encode like any other file, because nothing is parsed. A protected file still needs its password after decoding.
  • The output has no line breaks. Formats that need wrapped lines, such as MIME email at 76 characters per line, need that wrapping added afterwards.

Where Base64 PDFs are used

The most common case is an API that accepts documents inside a JSON body. E-signature, invoicing and document storage services often define a field that holds the file as Base64. Email attachments travel the same way under Content-Transfer-Encoding: base64, and SOAP or XML interfaces embed PDFs as base64Binary elements.

For a data URL, put data:application/pdf;base64, in front of the result. Keep the size cost in mind: four output characters for every three input bytes means a 3 MB document becomes 4 MB of text before any JSON overhead.

Frequently asked questions

Is my PDF uploaded when I convert it to Base64?

No. The page reads the file with the browser's File API and encodes it with JavaScript on your device. The document and the resulting string are never sent to a server.

What is the largest PDF I can convert?

The limit is 20 MiB, or 20,971,520 bytes, per file. Anything larger is refused before it is read, with a message that names the limit.

Why does a Base64 PDF start with JVBERi0?

PDF files begin with the bytes %PDF- and a version digit. Base64 turns those bytes into JVBERi0 every time, so the prefix works as a quick signature when you need to identify an encoded document.

How do I turn the Base64 string back into a PDF?

Use the Base64 to PDF tool on this site. It decodes the string, checks that the bytes begin with the PDF marker and offers the result as a file named decoded.pdf.

Does the output include the data:application/pdf prefix?

No. The Result box holds only the Base64 characters. If you need a data URL for an iframe, embed or link, type data:application/pdf;base64, directly before the string.

Related tools