Skip to content

PDF to Base64 Converter

Drop a PDF to get its Base64 string or a ready data:application/pdf URI, or paste Base64 to download the original PDF, without sending the document to a server.

100% Free • No Signup • Zero Uploads (Runs Locally)

100% Local Browser Execution • Zero Server Uploads • Air-Gap Safe

100% Local Tool Execution • Tool Inputs Never Leave Your Browser btoa/atob + File API

Drop a PDF, image or any file

Encoded in this tab, up to 50.0 MB.

or drag and drop it here · stays on this device

CtrlEnter to copy output

Wrong result, broken layout or an idea? Tell us about this tool.

PDF to Base64 Converter Base64 6-Bit Encoding and File Signature Detection & Security Architecture Banner

This online Base64 decoder and encoder converts text to Base64 and back, handles URL-safe base64url and data: URIs, and turns any file, a PDF, an image or a certificate, into Base64 without uploading it. Decoded output is checked against common file signatures, so a pasted blob that is really a PDF, ZIP or Windows executable is labelled before you save it. Everything runs with the browser’s btoa, atob and File APIs in this tab.

Why convert a PDF to Base64?

APIs and JSON payloads cannot carry raw binary, so e-signature, invoicing, OCR and email APIs expect documents as Base64 strings. A data: URI also lets you embed a PDF directly in HTML.

Typical fields are "file": "JVBERi0xLjcK…" or "content_base64". Every Base64-encoded PDF starts with JVBERi0, the encoding of %PDF-, which is a quick way to recognise one in logs or payloads.

How do you convert Base64 back to a PDF?

Paste the Base64 or data: URI into the Decode Base64 tab. The tool detects the PDF signature, shows the size and offers a .pdf download that you open locally.

If the download will not open, the string was probably truncated (check the length is a multiple of 4 once padding is added) or double-encoded. Copying from a JSON field can also leave \n escapes; remove them before decoding.

Also searched as: pdf to base64, convert pdf to base64, base64 to pdf, pdf base64 encoder.

How Base64 encoding works

Base64 (RFC 4648) splits input bytes into groups of three (24 bits) and writes each 6-bit slice as one of 64 printable characters: A–Z, a–z, 0–9, + and /. A final group of one or two bytes is padded with =. The output is always about 33% larger than the input: 3 bytes become 4 characters.

Base64 is an encoding, not encryption. Anyone can decode it, so a Base64 string in a config file or HTTP header is as readable as plain text. Treat Authorization: Basic values and Kubernetes Secrets as secrets, not as protected data.

How it works: Base64 Encoder & Decoder

PDF to Base64 Converter Base64 6-Bit Encoding and File Signature Detection & Security Architecture Diagram. Diagram of Base64 encoding: three input bytes split into four 6-bit groups mapped to the Base64 alphabet, with padding, base64url and data: URI variants, and file signature detection on decode.
Diagram of Base64 encoding: three input bytes split into four 6-bit groups mapped to the Base64 alphabet, with padding, base64url and data: URI variants, and file signature detection on decode.

Standard Base64, base64url and MIME line wrapping

The same bytes can be written in a few accepted forms. The decoder accepts all of them; the encoder lets you pick.

  • Standard (RFC 4648 §4): + and / with = padding, used in email, PEM and most APIs.
  • base64url (RFC 4648 §5): - and _ without padding, used in JWTs, URLs and file names.
  • MIME (RFC 2045): standard alphabet wrapped at 76 characters per line, used in email attachments.
  • data: URI (RFC 2397): data:application/pdf;base64,…, used to embed images and PDFs in HTML, CSS and JSON.

Converting a PDF or image to Base64

Drop the file in the File to Base64 tab. It is read with File.arrayBuffer() and encoded in memory, so contracts, invoices and ID scans never leave your device. Turn on data: URI to get a string you can paste into an <img src>, an <iframe> or a JSON API field that expects an embedded document.

Going the other way, paste Base64 or a data: URI into Decode Base64. The tool reports the size and detected type (PDF, PNG, JPEG, GIF, ZIP, gzip, MZ or ELF executable) and offers a download with the right extension. Binary content is never rendered or executed.

Base64 in security investigations

Attackers use Base64 to smuggle payloads past simple filters: PowerShell -EncodedCommand, HTML smuggling with data: URIs, and MIME attachments in phishing mail. A decoded blob that starts with MZ is a Windows executable and %PDF is a PDF. For layered obfuscation such as gzip inside Base64 inside PowerShell, use the [log deobfuscator](/tools/log-deobfuscator/), which decodes recursively.

Base64 quick reference

Signatures and sizes you will meet when decoding Base64.
Base64 starts withDecoded bytesMeaning
JVBERi0%PDF-PDF document
iVBORw0KGgo\x89PNGPNG image
/9j/FF D8 FFJPEG image
UEsDBAPK\x03\x04ZIP, DOCX, XLSX, JAR
H4sI1F 8B 08gzip stream
TVqQMZWindows executable or DLL
eyJ{"JSON, often a JWT segment

Signatures and sizes you will meet when decoding Base64.

Command-line examples

Encode and decode on Linux or macOS

base64 -w0 file.pdf > file.b64   # macOS: base64 -i file.pdf
base64 -d file.b64 > file.pdf

Encode a file in PowerShell

[Convert]::ToBase64String([IO.File]::ReadAllBytes("file.pdf"))

Decode with OpenSSL

openssl base64 -d -A -in file.b64 -out file.pdf

Frequently asked questions

Drop the PDF on this page and copy the output. It is encoded in your browser, so the document is never uploaded.