Skip to main content
b64topdf

Base64 to PDF Converter

Convert Base64 to PDF online directly in your browser. Paste raw strings, data URIs, text files, or JSON payloads to preview and download.

Shortcut: Ctrl / Cmd + Enter

Browser decoding for Base64 PDFs, without server uploads

APIs often dump PDFs inside JSON strings, and email gateways still wrap binary attachments in 76-character ASCII blocks. When you need to convert Base64 to PDF online without writing a Python script or trusting a third-party server with private invoices, you need a decoder that handles formatting quirks right in the browser. Paste a raw string, drop a .txt file or .json payload, or load a data URI into the editor above to decode Base64 to PDF and save a working .pdf file.

Most web decoders fail on trailing quotes or JSON wrappers. This tool strips dirty input formatting automatically while keeping every byte on your own device. Open DevTools, switch to the Network tab, and run a test conversion to confirm zero upload traffic leaves your browser.

How this Base64 to PDF converter cleans messy payloads

Copying a Base64 string from a browser console, Postman response, or database dump rarely yields clean text. A single trailing quotation mark, escaped \n newline, or data:application/pdf;base64, prefix trips strict browser APIs like atob(), which throws an InvalidCharacterError DOMException on non-alphabet characters according to the MDN Window.atob() documentation.

Before decoding a single byte, this converter trims outer whitespace and strips matching quotes. It removes RFC 2397 data URL prefixes, handles both standard +// strings and URL-safe -/_ variants defined in RFC 4648 Section 5, and ignores line breaks from RFC 2045 MIME wrapping. Copied a string out of a JSON log with literal \n, \r, or \t escapes? The cleanup loop drops those too, then restores missing trailing = padding when the character count misses a four-character boundary.

JSON API responses get dedicated parsing so you don't have to dig through nested brackets with Find and Replace. Paste an entire JSON object or array, and the scanner walks up to 200 candidate string properties locally. Any field starting with JVBERi shows up in the selector dropdown tagged as a PDF alongside its estimated byte size, so picking the right attachment takes one click.

Once decoding finishes, the converter reads raw magic bytes instead of blindly saving garbage with a .pdf extension. Under RFC 8118 and ISO 32000, PDF streams begin with the five ASCII bytes %PDF-, and practical readers scan the first 1,024 bytes for that signature. After confirming the header, the tool extracts PDF version, page count, encryption state, and document metadata (title, author, creator, producer, creation date) locally before opening the inline preview. You also get one-click buttons to open the local Blob URL in a dedicated browser tab or trigger printing directly.

Why local browser decoding protects private files

Uploading bank statements, signed employment contracts, medical records, or tax returns to a remote conversion server adds unnecessary risk. Running the decoder in your browser's own memory means there are no remote upload queues or server retention logs. Every byte stays inside your active tab until you close it.

Base64 expands binary data by roughly 33.3% because every 3 bytes turn into 4 six-bit ASCII characters, as noted in the MDN Base64 glossary, and 76-character MIME line breaks push total expansion near 37%. Pasting a 20 MB Base64 dump into an ordinary text box can stall a browser tab, and even client-side tools hit RAM limits on huge multi-hundred-megabyte payloads where a streaming CLI binary stays faster. For everyday 1 MB to 50 MB documents, dropping a .txt or .json file keeps the raw string out of the DOM editor and decodes it in 256 KB chunks inside a background Web Worker with a live progress bar.

Browser PDF viewers vary across devices too. Mobile Safari and locked-down corporate browsers sometimes disable inline PDF plugins (navigator.pdfViewerEnabled). When native iframe viewing is unavailable, this page switches to Mozilla's PDF.js engine and renders each page onto an HTML canvas with page-by-page controls.

When decoded bytes are not a PDF

API fields named fileData or documentBase64 often hold scanned PNG receipts, JPEG photos, or ZIP archives instead of PDFs. Rather than outputting an unreadable file, our byte detector inspects signatures across 27 formats (including PNG, JPEG, WEBP, GIF, ZIP, DOCX, XLSX, GZIP, MP4, MP3, and plain UTF-8 text).

Non-PDF payloads trigger a clear warning, render an inline preview for images, and adjust the download extension automatically. Need to inspect hex dumps, pretty-print JSON or XML, decode a JWT, or unpack Gzip streams? Open the Base64 Decoder tab. For multi-file batches or reverse encoding, switch to the Bulk Converter or the PDF to Base64 tool.

Three checks before you decode Base64 to PDF

If you try to convert Base64 to PDF and an application rejects the file, check these details first:

  1. Check the first six characters. %PDF- encodes to JVBERi in Base64, whereas iVBORw0 marks a PNG image and UEsDB indicates a ZIP or Office document.
  2. Inspect the final characters for truncation. Terminal logs often clip the last line, leaving 1 orphaned Base64 character that cannot form a complete 8-bit byte.
  3. Strip stray backslashes or log timestamps. Strict RFC 4648 Section 3.3 parsers reject non-alphabet bytes, so stray punctuation outside quotes halts decoding immediately.

Frequently Asked Questions

Can ChatGPT decode Base64?

ChatGPT cannot reliably decode Base64 PDF files directly in standard text chat because language models predict tokens rather than running exact byte math, and one wrong character ruins PDF cross-reference tables. Large encoded PDFs also exceed prompt context limits quickly. You can upload a .txt file and ask ChatGPT's Data Analysis Python sandbox to decode it via Python's base64 module, though sending private PDFs to an external AI server compromises local privacy.

What are illegal Base64 characters?

Standard Base64 under RFC 4648 permits only 65 characters: A through Z, a through z, 0 through 9, plus (+), slash (/), and up to two trailing equals (=) padding characters. URL-safe Base64 substitutes hyphen (-) for plus (+) and underscore (_) for slash (/). Any character outside those sets (spaces, newlines, quotes, backslashes, punctuation like @ or #, or non-ASCII bytes) is illegal under strict RFC 4648 decoding, although MIME decoders tolerate line breaks and this Base64 to PDF converter cleans whitespace, quotes, and data: prefixes automatically.

Can I convert a Base64 file online?

You can convert Base64 .txt or .json files to PDF online directly on this page with no software installation or server upload. Drop a single file onto the upload zone above (files over 1 MB stay in memory to keep the page fast), or open the Bulk Converter tab to process multiple .txt files at once into a downloadable ZIP archive.

What is Base64 used for?

Base64 translates raw binary bytes into printable ASCII characters so binary files survive text-based channels without byte mangling. Developers use it to send email attachments under MIME (RFC 2045), return PDFs inside JSON or XML API responses, embed small assets in HTML or CSS via RFC 2397 data URIs, and encode JSON Web Token (JWT) headers plus payloads.

How to convert Base64 to readable format?

Paste the string into a decoder that identifies what the raw bytes represent instead of forcing everything into plain text. When the bytes contain UTF-8 text, JSON, HTML, XML, or a JWT, the Base64 Decoder tab displays readable formatted text across UTF-8, UTF-16, ISO-8859-1, or Windows-1252. When the bytes begin with %PDF- (JVBERi in Base64), using this Base64 to PDF online tool renders the document inline with metadata.

How to convert to Base64 manually?

To encode by hand, convert each input character to 8-bit binary, join the bits into 24-bit groups, split each group into four 6-bit numbers (0 to 63), and map each number to the RFC 4648 Base64 alphabet (A to Z, a to z, 0 to 9, +, /), adding = or == when the final group has fewer than 3 bytes. For real PDFs, built-in CLI tools handle the math instantly: run base64 file.pdf on Linux or macOS, certutil -encode file.pdf out.txt on Windows, or drop the file into our PDF to Base64 converter.

How to download from Base64?

Paste your Base64 string, data URI, or JSON payload into the input box above (or upload a .txt or .json file) and click Convert to PDF. Once the converter verifies the file signature and loads the output card, edit the filename if needed and click Download PDF, or click Download File when the tool detects a non-PDF format.

Technical references