PDF to Base64 Converter
PDF to Base64 converter: choose a PDF and encode PDF to Base64 for JSON, HTML, or an API request. Copy a raw Base64 string, a PDF to Base64 data URI, or a wrapped JSON value, and check the file size and encoded size before you use it. The PDF is read locally and never uploaded.
In WeChat, downloads and image copy may be blocked. If a button does not respond, tap ··· in the top-right corner and choose Open in Browser.
File
Drop a file here or browse. Max 300 MB. Files are read locally and never uploaded.
- File
- base64box-sample.pdf
- MIME type
- application/pdf
- Source size
- 630 B
- Base64 size
- 840 B · 840 chars
- Overhead
- +33%
Selected images
PDF to base64 reads a document file and returns its bytes as a Base64 string or a data:application/pdf;base64, URI that can travel inside HTML, JSON or an email template, with the file read in your browser tab. A contract or an invoice never reaches a server.
Use it when a single-file report has to open without network access, when a JSON record must carry a small PDF attachment, or when an <a> link needs to download a document from a page with no backend. Because the encoder is generic, its output is byte-identical to what base64 or an SDK would produce. The whole step, including the data URI prefix, happens locally, which keeps confidential contracts out of third-party logs.
How to use
- Choose the PDF. Drop the file onto the panel or browse for it. The limit is 20 MB, and the details table immediately lists the file name, MIME type, source size and Base64 size with the overhead percentage.
- Pick an output format. Copy as offers Data URI, Plain Base64, HTML link, JSON and XML. The data URI is the form to paste into
srcorhref; JSON is handy when the value belongs in an API payload. - Copy or download. Copy output takes the full pdf to base64 string, and Download saves
{name}-base64.txt. A 1 MB PDF becomes about 1.4 MB of text, so expect a large file for a large document.
Size math, headers and embedding
The encoding itself is simple; the decisions that matter are about where the string will live and how much of it a browser will accept.
Encode pdf to base64 and check the MIME type
The details table reports application/pdf when the browser recognizes the file. A .pdf renamed from something else may be reported as application/octet-stream, and the encoded bytes will not start with JVBERi0 (the Base64 form of %PDF-1.4). Check that prefix before sending the value to a decoder, because a correct string for the wrong file is still the wrong file. The MIME row is worth reading too: a PDF exported by a scanner app is still application/pdf, while a downloaded file with the wrong extension may be something else entirely.
The pdf to base64 data uri in HTML and email
data:application/pdf;base64, followed by the payload works in an <iframe> in most desktop browsers and in a download link with the download attribute. Gmail and Outlook strip or block data URI links, and Chrome refuses top-level navigation to some data: URLs, so for email prefer a hosted file. The HTML link template produced by the tool shows the exact markup. Keep the string on a single line: a newline inside the payload breaks an href, even though the decoders on this site ignore it.
A pdf to base64 converter versus the command line
The command line is better for batches and for files above 20 MB: base64 -i invoice.pdf -o invoice.b64 on macOS or base64 invoice.pdf > invoice.b64 on Linux produces the same characters with line breaks every 76 columns. Those breaks are ignored by decoders here, so a .b64 file from a terminal can be pasted without cleaning. Use the JSON option when the string must sit beside a filename and a size.
FAQ
How do I build a pdf to base64 data uri?
Choose the Data URI output and the tool writes data:application/pdf;base64, followed by the payload. Paste that whole string into an iframe, a download link or a CSS rule. The plain Base64 option leaves the prefix off when the receiving system already knows the type.
How large does a PDF become after encoding?
About one third larger. A 1 MB PDF produces roughly 1.4 MB of characters. The 20 MB limit applies to the PDF itself, not to the encoded text, so a file close to the cap yields an output around 27 MB. The overhead row updates as soon as the file is read.
Is my PDF uploaded to a server?
No. The file is read with the File API and encoded in memory, so a pdf to base64 value is produced entirely on your device. Contracts, invoices and identity documents can be encoded without being sent anywhere or written to a log.
Why does encoding fail on a large PDF?
The panel stops at 20 MB and shows “File is too large for browser-side processing.” Split the document, compress the images inside it, or use the command line, which has no browser memory limit. The encoded text is held twice while the output box is filled.
Can I open the encoded PDF again?
Yes. Base64 to PDF decodes the same string, checks the %PDF signature and previews the document before download. That round trip is the quickest way to verify a pdf to base64 value before shipping it in a template.
Related tools
Base64 to PDF reverses this page and verifies the document header, which is the fastest check that an encoded value is intact. Image to Base64 Converter applies the same encoder to pictures and offers CSS and Markdown wrappers that a PDF does not need. Text to Base64 covers short plain strings in any language. Every result produced here opens in the decoder without removing line breaks or editing a single character.