PDF to Base64 converts a PDF file into a text string that can travel through JSON, HTML, CSS, email or Markdown. Add the PDF from your device, Google Drive or Dropbox, choose Plain Base64 or Data URI, decide whether to wrap the output, then copy the result or download it as a .txt file. Everything runs in your browser, so the PDF never leaves your device. The output is about 33% larger than the original — that is normal for base64 encoding.
What is PDF to Base64 conversion?
Base64 is an encoding scheme that turns binary data into ASCII text. A PDF is binary, so the bytes are grouped into 3-byte chunks and remapped into 64 printable characters — A–Z, a–z, 0–9, + and /. The result is a long ASCII string that can travel through any text channel without corruption.
That property matters because many systems treat payloads as text: JSON APIs, HTML attributes, CSS url() values, email attachments, YAML config files, Markdown links and log files. Base64 lets a PDF travel through them unchanged, so you can embed a document in an API response, inline it in a web page, or store it inside a config value without escaping problems.
The trade-off is size — base64 is roughly 33% larger than the raw bytes because 3 bytes become 4 characters. That is why base64 is used for embedding and transport, not for long-term storage. The formal definition is in RFC 4648, and you can read the background on the Base64 Wikipedia page.
How to convert PDF to Base64 in 5 steps
The process is short and needs no account. Follow these steps and the first string will be ready in seconds.
- Add your PDFDrag a PDF onto the upload card, click Browse, or import directly from Google Drive or Dropbox. The tool reads the file inside your browser, so nothing is uploaded to a server.
- Preview and check sizeThe PDF opens in an embedded preview on the left, alongside the file name and size. Confirm you picked the right document before continuing.
- Choose the output formatPick Plain Base64 for a raw string, or Data URI for an embeddable link (data:application/pdf;name=…;base64,…). Add a filename if you use the Data URI form.
- Adjust encoding optionsSwitch on Wrap lines to break the base64 at 76 characters — the MIME standard — or leave it unwrapped for a single line. Enable Auto-copy if you want the string on your clipboard immediately.
- Copy or downloadPress Copy to put the base64 on your clipboard, or download it as a .txt file. Press Convert another PDF to start over.
The tool reads the file with the browser's FileReader API and encodes it in JavaScript, so the output appears instantly after upload — no server round-trip, no queue.
Everything the converter can do
| Setting | Options | What it does |
|---|---|---|
| Output format | Plain, Data URI | Raw base64 string, or the same string wrapped in a data:application/pdf;name=…;base64,… header. |
| Filename | Custom | Sets the name= field inside the Data URI header. |
| Wrap lines | On or off | Breaks the output at 76 characters to match the MIME standard. |
| Auto-copy on upload | On or off | Puts the base64 on your clipboard immediately after upload. |
| Copy button | Always available | Copies the current output to your clipboard. |
| Download .txt | Always available | Saves the output as a text file. |
| Import sources | Device, Google Drive, Dropbox, clipboard | Loads the PDF without leaving the browser. |
Plain Base64 vs Data URI
The two formats contain the same encoded bytes. The difference is the small header that tells a browser what the data is.
Plain Base64
Just the string. Paste it into a JSON field, a config value, a database column, or send it to a decoder. No header, no assumptions about where it will be used.
Data URI
A full URI that starts with data:application/pdf;name=filename;base64,. Paste it into an HTML embed, a CSS url(), an img src or a Markdown link and the browser will open it.
When to use which
Use Plain Base64 for APIs and stored data. Use Data URI when you need something a browser can open directly from a single string.
Heads-up: Many browsers block navigating to a top-level data: URL for security reasons. A Data URI still works inside <embed>, <iframe> and CSS, but pasting it into the address bar may do nothing. Use Download .txt or save the decoded output as a PDF instead.
Line wrapping at 76 characters
RFC 2045 and MIME define 76 characters per line for base64 attachments. Email clients and some decoders expect that limit, and it is also the default for the Unix base64 command. Switch Wrap lines on to match.
| Wrap | Best for | Watch out for |
|---|---|---|
| Off (single line) | JSON values, config files, code strings | Some editors slow down on very long lines |
| On (76 chars) | Email, MIME, tools that expect wrapped base64 | You must strip newlines before pasting into JSON |
A single 5 MB PDF becomes about 6.7 MB of text. Your clipboard and editor handle it fine, but some APIs reject request bodies over a few megabytes, so check the limit before pasting.
Your PDF stays private
Everything happens in your browser. The PDF is read with FileReader, encoded in JavaScript, and displayed in a textarea. Nothing is uploaded, logged or stored. When you close the tab, the file is gone from memory.
- Local processing. File reading and base64 encoding both run on your device, so confidential documents never leave your computer or phone.
- Direct cloud downloads. When you import from Google Drive or Dropbox, your browser fetches the file straight from that provider after you grant access.
- No account needed. You can convert without signing in. Read our privacy policy for details about the site itself.
Tips for the best results
- Treat base64 as text, not encryption. Anyone can decode the string. If you need real protection, encrypt the PDF before encoding it.
- Compress before encoding. A smaller PDF means a smaller base64 string. Run it through our Compress PDF tool first.
- Use Data URI only when a browser must open it. For storage and APIs, plain base64 is clearer and easier to validate.
- Strip whitespace before decoding. Wrapped output contains newlines that some decoders reject. Remove them, then decode.
- Watch for size limits. Some APIs cap request bodies at 1–10 MB. A 5 MB PDF becomes 6.7 MB of text, which may exceed those limits.
- Keep the original file name. The Data URI header includes the filename, which helps when the receiver saves the decoded PDF.
Common problems and quick fixes
| Problem | Likely cause | Fix |
|---|---|---|
| Base64 doesn't open as a PDF | The header was included in a plain-base64 field | Strip the data:application/pdf;base64, prefix, or use Plain Base64 format. |
| API rejects the request | Body too large | Compress the PDF, or upload the file directly instead of embedding it as base64. |
| Decoded PDF is broken | Newlines from wrapped output | Remove the newlines before decoding, or use unwrapped output. |
| Empty result after upload | The PDF is zero bytes or unreadable | Try the file again; if it still fails, the file may be corrupted. |
| Text looks fine but is very slow | Multi-megabyte output in the textarea | Copy or download the file rather than scrolling; the textarea is not optimized for viewing megabytes. |
| Cloud import fails | The sign-in window was blocked | Allow pop-ups for this site, then press the Drive or Dropbox button again. |
Import from Drive and Dropbox, then share
You do not need to download the PDF to your phone first. The upload card includes Google Drive and Dropbox buttons, and the editor toolbar repeats them. The provider opens its own file picker, you select the PDF, and the tool downloads it into the page with a live progress bar.
After conversion, the share panel appears under the download button. You can post a link to the tool on WhatsApp, Facebook, X, LinkedIn or Telegram, send it by email, or copy the link. On phones and tablets that support the Web Share API, the Share .txt file button opens the system share sheet with the encoded file attached.
Related PDF tools
These pair naturally with PDF to Base64 and are all free.
Frequently asked questions
Is the PDF to Base64 converter free?
Does the tool upload my PDF to a server?
Can I import PDFs from Google Drive or Dropbox?
What is the difference between Plain Base64 and Data URI?
What does Wrap lines do?
What does Auto-copy on upload do?
Will the base64 be larger than the original PDF?
Can I open the base64 back into a PDF?
Does it work on iPhone and Android?
Is there a file-size limit?
Is base64 secure?
Can I share the tool with someone?
Ready to encode your PDF?
Load a PDF, choose Plain Base64 or Data URI, and copy or download the output in seconds. Free, private and built for every device.
Convert PDF to Base64