What This Tool Does

This bidirectional converter turns image files into Base64-encoded data URIs (ready to paste into HTML, CSS, or JSON), and decodes Base64 strings back into viewable, downloadable images. Useful for embedding small images in emails, inlining CSS background images, or working with image APIs that return Base64 strings.

Inputs Explained

How It Works

Encoding: FileReader.readAsDataURL converts the uploaded image into a data URI like 'data:image/png;base64,iVBOR...'. Decoding: the tool parses the MIME type from the prefix, decodes the Base64 to bytes, and creates a Blob for display and download.

Formula / Logic Used

Encode: file → FileReader.readAsDataURL() → 'data:image/...;base64,...' Decode: base64 → atob() → Uint8Array → Blob → URL.createObjectURL()

Image to Base64 & Base64 to Image

Convert images to Base64 data URIs for inline HTML/CSS — or decode Base64 back to images.

Step-by-Step Example

Encoded Base64 data URI for a tiny red pixel PNG:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==

Usage in HTML: <img src="data:image/png;base64,iVBOR...">

Usage in CSS: background: url('data:image/png;base64,iVBOR...');

Decoding the above returns a 1×1 red pixel PNG image.

Use Cases

Assumptions and Limitations

Disclaimer: Conversion runs entirely in your browser. Images are never uploaded to any server. Base64 encoding is reversible with no loss — the decoded image is byte-identical to the original.

Frequently Asked Questions

What is Base64 encoding?

Base64 encodes binary data (like image bytes) as text using 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). This lets binary data travel through text-only channels like JSON, XML, email, or source code.

Why is Base64 output 33% larger than the original file?

Base64 uses 4 characters to represent 3 bytes of binary data, so output is exactly 4/3 = 1.33× the input size. This overhead is the tradeoff for being able to include binary in text formats.

When should I use Base64 images?

Use for very small icons (< 2 KB), single-file HTML demos, email templates needing guaranteed display, and JSON API payloads. Avoid for large images or photos — use regular file URLs which cache better.

What's a data URI?

A data URI is a URL starting with 'data:' that contains the actual data inline. Format: 'data:MIME;base64,BASE64DATA'. Browsers treat them like any other URL but the data is in the URI itself, not fetched separately.

Can I decode any Base64 string?

Yes, but the result is only an image if the Base64 encodes image bytes. If you paste Base64 of plain text or other data, decoding produces that data, which won't display as an image. The tool defaults to PNG MIME when no prefix is given.

Does Base64 compress the image?

No — Base64 actually makes the file larger (by 33%). It's an encoding, not compression. Compress your image first (JPG/WebP), then Base64-encode if needed for inline embedding.

Will Base64 images work in email?

Mostly yes. Gmail, Outlook (most versions), and Apple Mail support data URIs in HTML emails. Gmail has a 102 KB email size limit though, so keep total Base64 weight modest.

Is my image uploaded?

No. All encoding/decoding happens in your browser using FileReader and native atob/btoa functions. Your image and Base64 strings never leave your device.

Sources and References

Related Calculators

Base64 EncoderImage CompressorImage Format ConverterImage ResizerURL EncoderHash Generator