PDFVela — pdfvela.com

How to save a Base64 string as a PDF file

An API response, an invoice XML or a raw email has a long block of text starting with JVBERi0, and you need the document inside it — from finding the code to opening the file.

By · Updated November 10, 2026

What is a Base64 PDF and why does it arrive as text?

Base64 writes a file using only letters, digits and a few symbols. That lets text-only formats — JSON, XML, email — carry a PDF inside them. The code holds an exact copy of the document; decode it and you get the original file back, byte for byte, with any digital signatures still valid.

You typically run into it in these places:

  • Invoicing and accounting APIs. E-invoicing platforms and accounting software often return the PDF version of an invoice as a Base64 field. Structured invoice XML (such as UBL) can embed the printable PDF the same way.
  • Shipping. When you create a shipment, carriers usually return the label as a Base64 PDF.
  • Payments and banking. Receipt, payslip and statement services may hand the document back in a text field.
  • E-signature and document platforms. The signed document comes back from the signing service as Base64.
  • Email source. In the raw source of an email, PDF attachments are stored as Base64 blocks.

1. Find the code and copy all of it

  • JSON response: Find the field holding the PDF — it is often called pdf, content, data, document, file or label. The value starts with JVBERi0. Copy everything between the quotation marks. You can also copy the whole response; the tool finds the part starting with JVBERi0 by itself.
  • XML file: Find the element carrying the PDF (for example EmbeddedDocumentBinaryObject) and copy the text between its opening and closing tags. Line breaks are fine.
  • Email source: Open "Show original" or "View source". The PDF attachment is the block below the Content-Type: application/pdf and Content-Transfer-Encoding: base64 lines. Copy everything up to the next blank line.
  • Developer tools: In the browser's Network tab, open the response, right-click the field and choose "Copy value". It is far more reliable than selecting a long string by hand.

Because the code is so long, its end is easily cut off. After copying, check that what you pasted ends the same way as the source.

2. Convert the code and check the document

Open Base64 to PDF, press "Or type / paste text" and paste the code. As soon as it is decoded, the first page appears with the page count, PDF version and file size underneath. If the code is saved in a .txt file, simply choose that file.

The preview lets you check quickly:

  • Is it the right document? The invoice number, customer name or label details are visible on the first page.
  • Is the page count what you expected? Missing pages mean the code was only partly copied.
  • Is it password-protected? Then a note appears instead of the preview, and the file is still saved exactly as it is.

3. Save the PDF and open it

Press "Download PDF". The file is saved unchanged and opens in any PDF reader. From there it is up to you: collect a month's invoices into one file with Merge PDF, make it small enough to email with Compress PDF, or get an image of the first page with PDF to JPG.

What the start of the code tells you

The code starts withThe file inside
JVBERi0PDF document
data:application/pdf;base64,PDF document (data URI)
iVBORw0KGgoPNG image
/9j/JPG photo
UEsDBZIP, Word (.docx) or Excel (.xlsx)
PD94bWwgXML text (for example the invoice data itself)

The last row explains a common mix-up with e-invoices: some services send the invoice XML as Base64 instead of a PDF. Decoded, that code gives you readable XML text, not a document.

Common mistakes

Saving the code as a text file with a .pdf extension. The file still contains the Base64 text and the reader reports it as damaged. The code needs to be decoded.

Copying more than the value. If a stray "," or "status" ends up at the end of the code, it becomes invalid. Copy either just the value or the whole response — the tool extracts the code correctly from both.

Escaped line breaks. In JSON strings, the code may be split every 76 characters with \n. Those characters are not part of the PDF; the tool removes them automatically.

The wrong response. If the document is not ready yet, some APIs return an empty field or an error message. If the code is very short — a few hundred characters — it is most likely an error text, not a PDF.

A note on privacy

Base64 does not protect your document; it only changes its format. Avoid decoding invoices, contracts, medical reports or ID copies on sites that upload the file to a server. PDFVela's tool decodes the code on your device and keeps working even if you go offline after the page has loaded.

Ready to try it? It is free and your file stays on your device.

Open Base64 to PDF

Questions about converting Base64 to PDF

How can I tell that a string is a Base64 PDF?

The surest sign is that it starts with JVBERi0 — that is how %PDF-, the first characters of every PDF, look after encoding. A string starting with data:application/pdf;base64, is a PDF too. The code contains only letters, digits, + and /, and may end with one or two = signs.

Can I just paste the code into a file and name it .pdf?

No. Saving the text with a .pdf extension still writes text into the file, and a PDF reader cannot open it. The code has to be decoded back into bytes first. The Base64 to PDF tool does that in your browser.

Where is the PDF inside an e-invoice XML?

The printable version of an invoice usually sits in an element such as EmbeddedDocumentBinaryObject, marked with mimeCode="application/pdf". All the text inside that element is the Base64 code of the PDF. Some services send HTML or an XSLT stylesheet instead; that code does not start with JVBERi0.

The document is confidential. Is this safe?

PDFVela's tool decodes the code on your own device; neither the text nor the document is sent to a server. Base64 is not encryption — anyone with the code can open the document — so check whether a site uploads your file before pasting invoices, contracts or ID scans into it.

What if the code contains a picture?

Code starting with iVBORw0KGgo (PNG) or /9j/ (JPG) is an image. The Base64 to PDF tool notices this and points you to the Base64 to image tool. After saving the picture, you can turn it into a PDF with JPG to PDF if you need to.