Decode a Base64 PDF
- Dashboard
- Documentation
- API
Decode a Base64 PDF
This tool takes a Base64 string representing a PDF file, decodes it and returns the original PDF as a direct download. This is the reverse operation of our Base64 PDF encoder.
Why decode a Base64 PDF?
- Recover a PDF received in JSON: an API returns a signed document, an invoice or a report as a Base64 string in a JSON key. To view it, it must be decoded.
- API integration debug: confirm that the Base64 string returned by a third-party service corresponds to a valid and readable PDF.
- Archive recovery: extract a PDF from a JSON export, a database dump or a transaction log that contains it encoded.
- Email attachment verification: analyze the Base64 content of a MIME attachment to validate its integrity.
How to use the tool
- Paste the Base64 string into the input field.
- The
data:application/pdf;base64,prefix is optional: the tool detects it and automatically removes it if present. - Run the decoding. If the string is valid and represents a PDF, a download button appears.
- Download the reconstructed file and open it with your usual PDF reader.
Example of accepted string
data:application/pdf;base64,JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVy...
The same string without the prefix (starting from JVBERi...) is also accepted.
PDF format validation
A valid Base64 string does not guarantee that the decoded content is a PDF. Our tool performs an additional check: it verifies that the first decoded bytes correspond to the magic header %PDF- that every PDF file has at the start of the file (signature 0x25 0x50 0x44 0x46 0x2D).
If the decoded data does not start with this signature, the tool rejects the request with the message "Decoded data does not look like a PDF". This safeguard prevents offering you a file for download that won't open, and immediately signals an upstream format problem (truncated string, wrong file type, or non-binary content).
Direct download
The reconstructed PDF is served directly with an HTTP header Content-Disposition: attachment and MIME type application/pdf. Depending on your browser, the file opens in the built-in viewer or downloads to the default folder.
Security and privacy
Decoding is performed server-side for the duration of the request. The reconstructed PDF is never stored on disk or cached: it is computed in memory and streamed directly to your browser. Once the response is sent, the data is released.
For particularly sensitive documents (contracts, personal data), prefer local decoding with an offline tool (for example base64 -d on the command line) so that the content does not transit through any third-party server.
Difference with a Base64 image
Our tool is specific to PDFs: it refuses a string that decodes into an image, a ZIP archive or any other format. To decode a Base64 image (PNG, JPEG, GIF, WebP), use our Base64 image decoder, which validates the magic headers specific to image formats and offers a direct preview in the browser.
Frequently asked questions
What to do if the tool returns "Decoded data does not look like a PDF"?
The Base64 string decodes correctly, but the result does not start with %PDF-. This means either the string is truncated, or the original content is not a PDF (maybe an image, a Word document, or corrupt data). Check the source: the full string should start with JVBERi (Base64 equivalent of %PDF).
My PDF seems truncated after decoding, why?
This happens when the source Base64 string is not complete: incomplete copy-paste, poorly handled line break, or a database field that truncated the value. Check that the string ends correctly (often with one or two = padding characters) and that no stray character has slipped in.
Is the resulting PDF identical to the original?
Yes. Base64 is a lossless reversible encoding: the decoded byte sequence is strictly identical to the encoded byte sequence. Any difference in hash or opening behavior indicates an upstream problem (damaged string, wrong source).
Is the Data URI prefix mandatory?
No. Our tool accepts either the string with prefix (data:application/pdf;base64,...) or the raw string (from the Base64 data directly). The prefix is useful in an HTML context, but an API that returns the PDF in a typical JSON field provides it without prefix.
Are my spaces and line breaks in the string a problem?
No. The decoder ignores whitespace characters (spaces, line breaks, tabs) that may appear when the string has been formatted for display. Only valid Base64 characters are taken into account.
Example request
curl -X POST https://cdrn.fr/api/v1/tools/base64-pdf-decoder/execute \
-H "Content-Type: application/json" \
-d '{"text_encoded":"..."}'
Input schema
| Field | Type | Required | Default |
|---|---|---|---|
text_encoded |
text | ✓ | – |
Endpoints
GET https://cdrn.fr/api/v1/tools- lists every available toolGET https://cdrn.fr/api/v1/tools/base64-pdf-decoder- returns the schema for this toolPOST https://cdrn.fr/api/v1/tools/base64-pdf-decoder/execute- runs this tool with a JSON payload