Convert PDF to Base64
Drop a PDF file to get its Base64 string or a ready-to-paste Data URI — encoded locally, never uploaded.
Drag & drop a PDF here
or
Inspection Report
- Detected Type
- —
- MIME Type
- —
- Encoding
- —
- Input Length
- —
- Decoded Size
- —
- Padding Status
- —
- Data URI
- —
- File Signature
- —
- Preview Availability
- —
How to convert PDF to Base64
To convert a PDF to Base64, drag and drop the file onto the tool above (or use Choose File). The PDF is read and encoded entirely in your browser, and you can copy the result as plain Base64 or as a data:application/pdf;base64,... Data URI. The file never leaves your device.
How to Use
- Drag your PDF onto the drop zone, or click Choose File and pick it. Drag and drop is never the only way to add a file.
- The tool checks the file really is a PDF and shows its name, size and page-ready metadata in the inspector.
- Pick an output tab: plain Base64, Data URI, JavaScript or Python.
- Click Copy to copy the output, or Download to save it as a .txt file.
- Need the reverse? The Base64 to PDF tool decodes and previews the result.
Real Example
A 245 KB invoice.pdf produces a Base64 string of roughly 327,000 characters — Base64 output is always about a third larger than the binary file. The Data URI tab wraps the same data as data:application/pdf;base64,JVBERi0x..., ready to paste into an HTML attribute, a JSON field or a test fixture. Switching to the JavaScript or Python tab gives you the exact code that performs this same encoding.
Code Snippets
// Encode a PDF file as Base64 (browser)
const buffer = await file.arrayBuffer();
const bytes = new Uint8Array(buffer);
let binary = '';
bytes.forEach(b => (binary += String.fromCharCode(b)));
const base64 = btoa(binary);How PDF to Base64 Works
Base64 turns every three bytes of your PDF into four text characters from a 64-character alphabet, which is why the output is about 33% larger than the file. A Data URI simply prefixes that text with data:application/pdf;base64, so a browser or JSON consumer knows what it is holding. Because the encoding is done by your browser reading the file locally, the PDF is never transmitted anywhere — you can safely convert confidential documents like contracts or invoices.
Common Use Cases
- Embedding a PDF in a JSON payload for an API that only accepts text.
- Creating a Data URI to inline a small PDF in an HTML prototype.
- Storing a document in a database text column or a config file.
- Building test fixtures with real PDF content for a parser.
- Sending a document through a system that strips binary attachments.