All Articles
Base64 & Encoding·5 min read·October 2, 2026

How to Decode Base64 to PDF Documents in the Browser

Reconstruct PDF documents from raw Base64 strings directly in your browser using Blobs, Uint8Array, and URL.createObjectURL.

TBy Toolstack Engineering
Recommended Free Tool

Try Toolstack's Base64 File Decoder

Free, instantaneous, and processes 100% locally in your browser.

Open Base64 File Decoder

Many backend enterprise APIs return generated PDF invoices, tickets, and contracts as Base64-encoded strings inside JSON responses (e.g. `{"pdfBase64": "JVBERi0xLjQK..."}`).

Client-Side JavaScript PDF Generator

Instead of forcing the server to host a temporary file, you can convert the string into a real PDF in the user's browser memory: ```javascript function downloadBase64Pdf(base64String, filename = "document.pdf") { // 1. Decode Base64 to binary string const byteCharacters = atob(base64String); const byteNumbers = new Uint8Array(byteCharacters.length); for (let i = 0; i < byteCharacters.length; i++) { byteNumbers[i] = byteCharacters.charCodeAt(i); } // 2. Create Blob with application/pdf MIME type const blob = new Blob([byteNumbers], { type: "application/pdf" }); // 3. Trigger immediate download const link = document.createElement("a"); link.href = URL.createObjectURL(blob); link.download = filename; link.click(); URL.revokeObjectURL(link.href); } ```

You can also paste any Base64 string directly into Toolstack's Base64 File Decoder to preview and save the file with one click.

Tags:#PDF#JavaScript#Blobs#Browser APIs

More Guides in Base64 & Encoding