Base64 to PDF Converter
Paste a Base64 string or data URI, see the page count and first page, and save it as a PDF file.
or drop it anywhere on this page, or paste
Opens in your browser. Nothing is uploaded.
The tool accepts a data: URI prefix, line breaks, spaces, quotes, the URL-safe alphabet with - and _, and missing = padding. Nothing is uploaded.
Saves as decoded.pdf
!Paste Base64 text or choose a .txt file
Base64 to PDF Converter, free and private
This Base64 to PDF converter decodes a Base64 string back into a PDF file you can open and save. Paste the text or open a .txt file. The tool checks for the %PDF- header, counts the pages and shows page 1 before you download.
It accepts text the way APIs, emails and code hand it over. A data:application/pdf;base64, prefix, line breaks, spaces, quotes, URL-safe characters and missing = padding are cleaned up for you. Decoding runs in your browser, so the document is never uploaded.
How to convert Base64 to PDF
- 1
Paste the Base64 or open a .txt file
Paste the string into the box, or choose a .txt or .b64 file up to 200 MB. Text longer than 200,000 characters appears as a one-line summary instead of in the box, so typing stays fast.
- 2
Check the preview
About a third of a second after you stop typing, the tool decodes the text and opens the result. You see the first pages, up to three, with the page count, the PDF version and the file size. If the data is not a PDF, a message says what it is instead.
- 3
Name the file
Type a file name, or keep the name of the .txt file. The tool adds .pdf and replaces characters that Windows and macOS reject in file names.
- 4
Decode Base64 to PDF and download
Press Convert to PDF, then Download PDF. Preview opens the file in your browser's PDF viewer first.
Why use PDFToolz for this
Accepts messy input
Line breaks from email, JSON escapes like \n and \/, percent-encoded + / and =, the URL-safe - and _ alphabet and missing padding are fixed before decoding. A leading data: URI with any file type is removed, and so are the BEGIN and END lines that Windows certutil adds.
Names what the data really is
If the Base64 holds a PNG, JPEG, GIF, WebP or TIFF image, a ZIP archive such as a DOCX or XLSX file, gzip data or plain text, the message says so. You know at once that the wrong file was encoded.
Catches cut-off strings
A string with one character too many or too few, = padding in the middle, or a PDF without its %%EOF end marker gets a clear warning. These are the usual signs that only part of the text was copied.
Decodes double-encoded data
Some systems encode a PDF and then encode the result again. When the decoded text starts with JVBERi, which is %PDF- in Base64, the tool decodes it a second time and tells you it did.
Stays on your device
The text is decoded in chunks of 65,536 characters, and pdf.js draws the preview in the same tab. Neither the text nor the PDF reaches a server.
What the error messages mean
Each message points to a specific problem with the text:
- It decodes to a PNG image, a JPEG image or another format. The Base64 is valid, but it holds a different file. Ask the sender for the PDF, or save the image and turn it into a PDF with JPG to PDF.
- It decodes to plain text. The message shows how the decoded text starts, which often reveals an error message or an HTML page that was encoded by mistake.
- It contains a character Base64 never uses. Something besides the string was copied, such as a JSON key, a colon or a bracket. Paste only the value between the quotes.
- It has one character too many or too few. The string was cut off. Copy it again in full, or check whether the API that sent it truncates long fields.
- It has = padding in the middle. Two Base64 strings were joined together. Decode each one on its own.
- It is the raw content of a PDF. Text that starts with %PDF- is the PDF itself opened as text. Copying it as text damages the binary data, so you need the original file.
Where Base64 PDFs come from
JSON cannot carry raw bytes, so web APIs send files as Base64 text. Shipping label services, e-signature platforms, invoicing systems and email APIs often return a PDF this way, in a field named something like data, content or document.
Email attachments are stored as Base64 inside the message source, in lines of 76 characters. To recover one from the raw source of an email, copy everything between the blank line after the attachment headers and the next boundary line that starts with --.
Decoding Base64 to PDF on the command line
These built-in commands decode clean Base64. Unlike this tool, they do not remove a data: prefix or check that the result is a PDF:
- On macOS, run base64 -D -i input.txt -o output.pdf in Terminal.
- On Linux, run base64 -d input.txt > output.pdf. GNU base64 rejects the URL-safe alphabet, so convert - and _ back to + and / first.
- In PowerShell on Windows, run [IO.File]::WriteAllBytes("C:\docs\output.pdf", [Convert]::FromBase64String((Get-Content C:\docs\input.txt -Raw))). In Command Prompt, certutil -decode input.txt output.pdf does the same.
Limits
Text files up to 200 MB are accepted, which decode to a PDF of about 150 MB. A password protected PDF decodes fine, but the preview stays blank because the tool does not ask for the password. The downloaded file opens with its password in any PDF reader.
The tool does not repair a damaged PDF. If the header is there but the preview fails, download the file and run it through Repair PDF.
Frequently asked questions
Paste the Base64 string or open a .txt file, check the page preview and press Convert to PDF. It is free, and the decoding happens in your browser.
Paste it as it is. The tool removes the data URI prefix and decodes the rest. Prefixes with other types, like data:application/octet-stream;base64, work too.
The string decodes to a file without the %PDF- header that every PDF starts with. The message names the actual type, such as a PNG image or a ZIP archive, so you know what was encoded.
Yes. The text is decoded in your browser and the preview is drawn by pdf.js in the same tab. Nothing is uploaded, and scripts inside the PDF do not run.
No. Acrobat cannot open Base64 text at all. Decode it here first, then open the PDF in any reader, including the one built into your browser.
Yes. Paste the string in Safari or Chrome, or open a .txt file from the Files app. After you press Download PDF, the file is in your downloads.
It swaps + for - and / for _ so the string can sit in a URL, and it often drops the = padding. The tool converts it back before decoding, so you can paste it as it is.
Decode it with atob, copy each character code into a Uint8Array and wrap that in a Blob with the type application/pdf. Decode long strings in chunks to keep memory use steady.