What does the Base64 to Image Decoder do?
The Base64 to Image Decoder translates raw Base64 data strings and MIME Data URIs back into renderable PNG, JPEG, SVG, GIF, WebP, AVIF, and BMP image files. It inspects binary file header magic bytes to automatically identify image encodings, provides an instant visual canvas preview, and exports formatted HTML <img> tags, CSS background-image declarations, and direct file downloads.
Core Concepts
- MIME & Data URI Structure: A Data URI consists of the scheme (
data:), MIME type (image/png), charset/encoding identifier (;base64,), and the encoded payload. - Magic Number File Signature Detection: Even when MIME metadata is omitted from raw Base64 strings, binary file headers contain deterministic byte sequences (e.g.
89 50 4E 47for PNG,FF D8 FFfor JPEG,47 49 46 38for GIF). The engine inspects these signatures to identify the exact file extension. - SVG Vector Support: Raw SVG XML strings embedded in Base64 are detected and parsed into vector Data URIs for lossless rendering.
How to use the tool?
- Paste Base64 or Data URI: Input your Base64 encoded image string, CSS background asset, or complete
data:image/...Data URI into the editor or click Sample. - Review Live Visual Preview: The engine decodes the binary buffer, identifies image dimensions, format, and file size, and displays the image on a transparency grid in real time.
- Download File or Copy Code: Download the decoded image in multiple formats (PNG, JPG, WebP, SVG) or copy generated HTML
<img>, CSS background, and Data URI snippets.
Related Developer Utilities
- Base64 to Hex: Decode Base64 payloads into formatted hexadecimal byte streams.
- Hex to Base64: Convert raw hex byte streams into standard and URL-safe Base64 strings.
- Base64 Encoder: Encode raw UTF-8 text strings to standard and URL-safe Base64.
- Base64 Decoder: Decode Base64 payloads back to 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-image) for programmatic integration into CI/CD pipelines, image processing microservices, and AI agent workflows.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String / Object | Raw Base64 image payload or complete Data URI (aliases: text, payload, data, input, value). |
"data:image/png;base64,iVBORw..." |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/base64/base64-to-image \
-H "Content-Type: application/json" \
-d '{ "rawText": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" }'Python
import requests
url = "https://blueutils.com/api/base64/base64-to-image"
payload = {
"rawText": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
}
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\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==\"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/base64/base64-to-image"))
.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 Base64 image decoding succeeded. | true |
dataUri |
String | Complete normalized Data URI string. | "data:image/png;base64,..." |
mimeType |
String | Detected MIME type of the image. | "image/png" |
fileExtension |
String | Target file extension for saving binary asset. | "png" |
byteLength |
Number | Decoded binary image size in bytes. | 70 |
formattedSize |
String | Human-readable file size string. | "70 B" |
snippets |
Object | Generated HTML, CSS, and Markdown integration code snippets. | { "html": "...", "css": "..." } |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"dataUri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
"mimeType": "image/png",
"fileExtension": "png",
"isSvg": false,
"byteLength": 70,
"formattedSize": "70 B",
"snippets": {
"html": "<img src=\"data:image/png;base64,...\" alt=\"Base64 Rendered Image\" />",
"css": "background-image: url('data:image/png;base64,...');",
"markdown": ""
}
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Invalid Base64 format: String contains non-Base64 characters or corrupted padding."
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Why use an API to decode Base64 to Images?
Integrating the Base64 to Image API into automated backend pipelines provides significant architectural value:
- Automated Webhook & Camera Stream Ingestion: Decode embedded Base64 snapshots from IoT cameras, mobile apps, or payment receipts into binary files before database or S3 storage.
- Optimized Token Efficiency for AI Agents: LLMs cannot reliably render or inspect raw binary buffers in context. Offloading image decoding to Blueutils returns normalized Data URIs and dimensions instantly.
- Deterministic MIME Type Extraction: Guarantees accurate format detection based on binary magic bytes rather than unreliable user-provided filenames.
Native Usage
Decode Base64 strings to binary image files locally without external dependencies using native OS tools:
Windows (PowerShell)
# Decode Base64 string to PNG file in PowerShell
$b64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
$bytes = [System.Convert]::FromBase64String($b64)
[System.IO.File]::WriteAllBytes("image.png", $bytes)Linux / Unix (Bash)
# Decode Base64 string to PNG file using base64 CLI
echo "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" | base64 -d > image.pngPython
import base64
b64_str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
raw_bytes = base64.b64decode(b64_str)
with open("image.png", "wb") as f:
f.write(raw_bytes)Java
import java.io.FileOutputStream;
import java.util.Base64;
public class Base64ToImage {
public static void main(String[] args) throws Exception {
String b64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
byte[] bytes = Base64.getDecoder().decode(b64);
try (FileOutputStream fos = new FileOutputStream("image.png")) {
fos.write(bytes);
}
}
}