What does the Base64 to File & PDF Downloader do?
The Base64 to File Downloader decodes raw Base64 strings, RFC 2397 Data URIs, and URL-safe Base64 payloads into downloadable binary files including PDF documents, ZIP archives, images (PNG, JPEG, SVG, WebP, GIF), audio files (MP3, WAV), and video media.
It inspects magic header signatures (e.g. %PDF for Adobe PDF, PK\x03\x04 for ZIP, \x89PNG for PNG) to automatically identify the true MIME format and file extension even if the payload lacks a Data URI header.
Core Concepts
- Magic Byte Signature Inspection: Many Base64 payloads originate from APIs without MIME wrappers. The tool reads the initial 4 to 16 binary bytes of the decoded buffer to identify file formats accurately.
- RFC 2397 Data URI Parsing: Automatically strips leading
data:application/pdf;base64,...prefixes and respects declared MIME parameters. - URL-Safe Base64 Normalization: Automatically converts
-and_characters back to standard+and/characters and balances padding (=).
How to use the tool?
- Paste Base64 Payload: Enter your Base64 encoded PDF, ZIP, or binary string into the input editor or click Sample.
- Optional Overrides: Specify a custom filename or override the MIME type if necessary in the top master toolbar.
- Live Decode & Download: The tool detects file metadata and formats in real time. Click Download to save the reconstructed binary file to disk.
Related Developer Utilities
- Image to Base64: Convert image and SVG files into Base64 strings and Data URIs.
- Base64 to Image: Decode Base64 strings specifically into visual image canvas previews and multi-format exports.
- Base64 Encoder: Encode plain text strings into standard or URL-safe Base64 format.
- Base64 Decoder: Decode Base64 strings into UTF-8 text or formatted JSON.
REST API Integration
blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/base64/base64-to-file) for programmatic decoding in CI/CD pipelines, document microservices, and automated testing workflows.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String / Object | Raw Base64 string or Data URI to decode (aliases: text, payload, data, input, value). |
"JVBERi0xLjQK..." |
customFilename |
String | Optional filename override for output (aliases: filename). |
"report.pdf" |
customMime |
String | Optional MIME type override (aliases: mimeType). |
"application/pdf" |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/base64/base64-to-file \
-H "Content-Type: application/json" \
-d '{ "rawText": "JVBERi0xLjQKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqCnRyYWlsZXI8PC9TaXplIDIvUm9vdCAxIDAgUj4+CnN0YXJ0eHJlZgoxMDUKJUVPRg==" }'Python
import requests
url = "https://blueutils.com/api/base64/base64-to-file"
payload = {
"rawText": "JVBERi0xLjQKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqCnRyYWlsZXI8PC9TaXplIDIvUm9vdCAxIDAgUj4+CnN0YXJ0eHJlZgoxMDUKJUVPRg==",
"customFilename": "report.pdf"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String jsonPayload = "{\"rawText\": \"JVBERi0xLjQK...\"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/base64/base64-to-file"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}API Response Parameters
| Name | Type | Description | Example |
|---|---|---|---|
isValid |
Boolean | Indicates whether decoding succeeded. | true |
dataUri |
String | Complete RFC 2397 Data URI. | "data:application/pdf;base64,..." |
filename |
String | Suggested or overridden filename. | "downloaded_file.pdf" |
fileExtension |
String | Detected or overridden file extension. | "pdf" |
mimeType |
String | Detected or overridden MIME type. | "application/pdf" |
fileTypeLabel |
String | Human-readable file type label. | "PDF Document" |
byteLength |
Number | Decoded file size in bytes. | 300 |
formattedSize |
String | Human-readable byte size. | "300 B" |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"dataUri": "data:application/pdf;base64,JVBERi0xLjQK...",
"filename": "downloaded_file.pdf",
"fileExtension": "pdf",
"mimeType": "application/pdf",
"fileTypeLabel": "PDF Document",
"byteLength": 300,
"formattedSize": "300 B",
"isText": false,
"textPreview": null
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Invalid input: Base64 string or Data URI cannot be empty."
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Native Usage
Decode Base64 payloads into binary files locally on your machine using standard command line tools:
Windows (PowerShell)
# Decode Base64 string to file in PowerShell
$b64 = "JVBERi0xLjQK..."
$bytes = [System.Convert]::FromBase64String($b64)
[System.IO.File]::WriteAllBytes("output.pdf", $bytes)Linux / Unix (Bash)
# Decode Base64 string to file in Bash
echo "JVBERi0xLjQK..." | base64 -d > output.pdfPython
import base64
b64_string = "JVBERi0xLjQK..."
with open("output.pdf", "wb") as f:
f.write(base64.b64decode(b64_string))Java
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
public class Base64ToFile {
public static void main(String[] args) throws Exception {
String b64 = "JVBERi0xLjQK...";
byte[] bytes = Base64.getDecoder().decode(b64);
Files.write(Path.of("output.pdf"), bytes);
}
}