BASE64 TO IMAGE API
Convert base64 encoded image data to temporary URLs that are valid for 1 hour and automatically cleaned up within 24 hours. Perfect for temporary image sharing, testing, and development workflows.
SERVER
tools64.com
PLATFORM
Functions
VERSION
v1.0.0
BASE URL
https://tools64.com/api/base64-to-imagePOST Method
Convert base64 data to a temporary image URL that is valid for 1 hour and cleaned up within 24 hours.
Request Parameters
base64Data
Base64 encoded image data (supports both data URLs and raw base64)
mimeType
MIME type of the image (defaults to 'image/png')
Request Body
{
"base64Data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",
"mimeType": "image/png"
}Response
JSONReturns the generated image URL, cleanup message, and image ID
Code Examples
# Using curl
curl -X POST "https://tools64.com/api/base64-to-image" \
-H "Content-Type: application/json" \
-d '{
"base64Data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",
"mimeType": "image/png"
}'
# Using Python requests
import requests
import base64
# Read image file and convert to base64
with open("image.png", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
# Create data URL
data_url = f"data:image/png;base64,{encoded_string}"
response = requests.post("https://tools64.com/api/base64-to-image", json={
"base64Data": data_url,
"mimeType": "image/png"
})
if response.status_code == 200:
result = response.json()
print("Image URL:", result["imageUrl"])
print("Message:", result["message"])
print("Image ID:", result["imageId"])
else:
print("Error:", response.json())ENDPOINT EXAMPLES
Convert PNG to Temporary URL
POST /api/base64-to-imageConvert a PNG image from base64 to a temporary URL
Convert JPEG to Temporary URL
POST /api/base64-to-imageConvert a JPEG image from base64 to a temporary URL
Access Image Directly
Direct Blob URL accessUse the returned imageUrl directly in your application
CLEANUP BEHAVIOR
Image Validity Period
Images are considered valid for 1 hour from upload time. During this period, the image URL is fully accessible and functional.
Cleanup Schedule
Automatic cleanup runs once daily at midnight UTC. Images older than 1 hour are automatically deleted during this cleanup process.
Important Notes
- • Images may remain accessible for up to 24 hours after upload
- • Cleanup is based on the blob's
uploadedAttimestamp - • No manual expiration management required
- • Legacy images without proper timestamps are automatically cleaned up
ERROR HANDLING
The API returns appropriate HTTP status codes and error messages for various scenarios.
400 Bad Request
{
"error": "Missing base64Data parameter"
}400 Bad Request
{
"error": "Invalid data URL format. Expected: data:image/type;base64,data"
}400 Bad Request
{
"error": "Invalid MIME type: text/plain. Only image types are allowed."
}400 Bad Request
{
"error": "Base64 data too short. Minimum length is 10 characters."
}400 Bad Request
{
"error": "File too large. Estimated size: 15.2MB. Maximum allowed: 10MB."
}400 Bad Request
{
"error": "Invalid image format. Only PNG, JPEG, GIF, and WebP are supported."
}400 Bad Request
{
"error": "Failed to decode base64 data. Invalid base64 string."
}404 Not Found
{
"error": "Image not found or expired"
}410 Gone
{
"error": "Image has expired"
}429 Too Many Requests
{
"error": "Rate limit exceeded. Too many requests from this IP.",
"rateLimit": {
"limit": 10,
"remaining": 0,
"resetTime": "2024-01-01T12:00:00.000Z",
"retryAfter": 3600
}
}RATE LIMITS & USAGE
Rate Limits
10 requests per hour per IP
Best Practices
- • Use data URLs (data:image/type;base64,data) for better compatibility
- • Specify the correct MIME type for proper image handling
- • Keep images under 10MB for optimal performance
- • Supported formats: PNG, JPEG, GIF, and WebP
- • Store the imageUrl and imageId for future reference
- • Images are valid for 1 hour but cleanup happens within 24 hours - plan accordingly
- • Use for temporary sharing, testing, or development purposes only
Use Cases
- • Temporary image sharing in chat applications
- • Development and testing of image upload features
- • Quick image preview generation
- • Temporary image storage for user sessions
- • Prototyping image-based applications
READY TO TEST THE API?
Try out the Base64 to Image API with different image formats to see it in action.