Base64 to PDF Converter

Paste a Base64 string, a data URL, or a whole API response. The converter finds the PDF inside, repairs common copy-paste damage, checks the bytes, and gives you a file to preview or save. Nothing leaves your browser.

Decode Base64 to a PDF file

0 characters

Drop a .txt, .b64, or .json file on the box to load its text. The page takes up to 50 MB of text, about a 37 MB PDF.

Waiting for a string

Paste Base64 on the left, or press Load sample. Each check fills in here.

Open in new tab

Where Base64 PDFs come from

Nobody types a Base64 PDF by hand. The string comes out of an API, a log line, or a script, and each source wraps the bytes its own way. Knowing the source tells you what cleanup to expect.

Load sample fills the box with the kind of payload a shipping webhook sends: a JSON object with the delivery note for order TX-77310 under document.content and the file name one level up. The converter pulls out both, so the download keeps the original name.

What gets repaired before decoding

Most failed decodes trace back to damage picked up between the source and your clipboard. The converter runs these repairs in order and lists each one under What changed, so you see how the decoded string differs from your paste.

  1. JSON gets unpacked. When the paste parses as JSON, every field is checked and the string whose bytes start like a PDF wins. A field named filename or name supplies the download name.
  2. Quote marks come off. A value copied with its surrounding quotes, or with the trailing comma from the next line, loses them.
  3. The data URL prefix goes. Everything up to the first comma is read, then removed. A media type other than application/pdf gets flagged, but the bytes decide the verdict.
  4. Escapes turn back into characters. \/ becomes /, and literal \n or \r sequences copied out of logs disappear.
  5. Whitespace goes. MIME email bodies break the string every 76 characters, PEM-style output every 64. Spaces from a PDF or a chat window go too.
  6. URL-safe characters swap. - becomes + and _ becomes /. A string holding both alphabets is rejected, since that points to two strings glued together.
  7. Padding gets fixed. Missing = signs are added back. A string one character away from any valid length is rejected, because a lost character has no safe repair.
  8. Double encoding gets peeled. When the decoded bytes spell JVBERi0, the PDF went through Base64 twice, so the converter decodes once more.

A long What changed list says more about the sender than about the PDF. If your own backend ships a data URL prefix and line breaks to an API expecting raw Base64, fix the sender. The service on the other end won't run these repairs for you.

Spot the file type from the first characters

Every file format opens with a fixed byte signature, and Base64 turns each signature into a fixed run of characters. Read the start of the string and you know what you have before decoding anything.

Starts withDecodes toNext stop
JVBERi0%PDF-, a PDFThis page.
SlZCRVJpJVBERi, a PDF encoded twiceThis page. The second layer gets decoded for you.
iVBORw0KGgoA PNG imageBase64 to Image
/9j/A JPEG imageBase64 to Image
R0lGODA GIF imageBase64 to Image
UEsDBA ZIP container: DOCX, XLSX, PPTX, EPUB, or a plain ZIPBase64 to File
0M8R4KGxA pre-2007 Office file: .doc, .xls, .pptBase64 to File
JSFQU%!PS, a PostScript fileConvert with Ghostscript first. Readers won't open PostScript as a PDF.
PD94bWwg<?xml, XML textBase64 to Text
eyJ{", JSON textBase64 to Text. Often a JWT segment or an API error message.

The converter runs the same check on the decoded bytes. Paste a PNG by mistake and the result panel names the format and links to the right tool, instead of handing you a .pdf file no reader will open.

How strict your decoder is

The same string decodes in one language and fails in another. When your code rejects a string this page accepted, or worse, writes a file without complaint and the file won't open, check the row for your runtime.

DecoderLine breaks- and _Missing =data: prefix
atob() in browsersIgnoredInvalidCharacterErrorAcceptedInvalidCharacterError
Node.js Buffer.from(s, 'base64')IgnoredAcceptedAcceptedGarbage bytes, no error
Python base64.b64decode(s)IgnoredDropped, broken outputIncorrect paddingGarbage bytes, no error
PHP base64_decode($s)IgnoredDropped, broken outputAcceptedGarbage bytes, no error
Java Base64.getDecoder()IllegalArgumentExceptionIllegalArgumentExceptionAcceptedIllegalArgumentException
.NET Convert.FromBase64String()IgnoredFormatExceptionFormatExceptionFormatException

The amber cells are the dangerous ones. An exception tells you something broke. Silent garbage gets written to disk as invoice.pdf and fails three systems later. Before saving decoded bytes in any language, check the first five bytes read %PDF-. In Python, pass validate=True or use base64.urlsafe_b64decode for Gmail-style strings. In PHP, pass true as the second argument. In Java, getMimeDecoder() accepts wrapped lines and getUrlDecoder() reads the URL-safe alphabet.

Where this converter stops

Base64 to PDF questions

Blank tabs, damaged files, padding, and privacy.

Why does my data:application/pdf link open a blank tab?

Chrome, Edge, and Firefox block pages from sending the top window to a data: URL, a rule added in 2017 and 2018 to stop phishing pages posing as PDFs. Open in new tab on this page uses a Blob URL built from the decoded bytes, which browsers allow. In your own code, wrap the bytes in a Blob and pass URL.createObjectURL(blob) to window.open.

Is my PDF sent to Toolexe?

No. Decoding runs in JavaScript on this page, and the bytes live in a Blob in your browser memory. Toolexe never receives the string or the file. Closing the tab discards both.

The converter says the PDF is valid, but my reader says the file is damaged. Why?

Look at the Ending row. If the %%EOF marker is present, the string arrived whole and the PDF was already broken before encoding, so ask the source for a fresh copy. If the row says the end is missing, the string lost its tail during copying.

How do I tell a string holds a PDF before decoding?

A Base64 PDF starts with JVBERi0, the encoded form of %PDF-. A string starting with SlZCRVJp is a PDF encoded twice. Anything else is a different format, and the prefix table on this page tells you which.

Why did the converter add = signs to my string?

Standard Base64 length is a multiple of four, filled out with = signs at the end. URL-safe encoders often drop them. Adding them back changes no bytes in the PDF, and strict decoders such as .NET and Python refuse the string without them.

What does Header at byte N mean?

Some PDF writers and transfer steps put stray bytes before %PDF-. Adobe Reader tolerates up to 1,024 of them, and this page uses the same window. Strict libraries reject the file, so strip the leading bytes if another system refuses the file.