
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
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
| Base64 starts with | Decoded bytes | Meaning |
|---|---|---|
| JVBERi0 | %PDF- | PDF document |
| iVBORw0KGgo | \x89PNG | PNG image |
| /9j/ | FF D8 FF | JPEG image |
| UEsDBA | PK\x03\x04 | ZIP, DOCX, XLSX, JAR |
| H4sI | 1F 8B 08 | gzip stream |
| TVqQ | MZ | Windows 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.pdfEncode a file in PowerShell
[Convert]::ToBase64String([IO.File]::ReadAllBytes("file.pdf"))Decode with OpenSSL
openssl base64 -d -A -in file.b64 -out file.pdfFrequently asked questions
Drop the PDF on this page and copy the output. It is encoded in your browser, so the document is never uploaded.
Related tools
- Log DeobfuscatorDecode Base64, PowerShell, hex, URL and gzip with auto-detect, plus text-to-binary, dec-to-hex and an ASCII table.
- Hash & Checksum GeneratorSHA-256, SHA-512, SHA-1, MD5, CRC32, NTLM, HMAC and bcrypt for text, plus file checksums without uploading.
- JWT DecoderSplit a token into header, payload and signature, audit claims and verify HMAC signatures.