b2KIT

Base64 to Image Decoder

Decode base64 encoded image strings to visual preview with format detection and download.

Tested tool guide Tested browser tools Checked August 16, 2026

What Base64 to Image Decoder does, with a checked example

This tool takes a base64-encoded image string, such as the one pasted into an HTML src attribute or produced by a file-to-base64 converter, and renders it as a visible image inside the browser. It inspects the string's header to identify the image format and shows the detected type, dimensions, and MIME type. A base64 string without a proper data URI prefix (like 'data:image/png;base64,') may still decode correctly, and the format is then determined solely by the binary file signature. Nothing you paste leaves your computer.

Worked example

A concrete input and expected output from the current implementation.

Input

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==

Expected output

A 1x1 pixel red PNG image is displayed. Detected format: PNG (image/png), 1x1 pixels, size 68 bytes decoded.

The string's header 'iVBORw0KGgo' is the base64 encoding of the PNG signature bytes 89 50 4E 47 0D 0A 1A 0A, so the tool identifies PNG. The image data itself encodes a single red pixel, and decoding the base64 yields 68 bytes.

How the result is produced

1

Format detection from the header

The tool reads the first few characters of the base64 string, which correspond to the binary file signature. PNG starts with 'iVBOR', JPEG with '/9j/', GIF with 'R0lG', and WebP with 'UklGR'. It uses these signatures to label the output format and MIME type. If the string has a data URI prefix, it may also parse the MIME type from that prefix.

2

In-browser rendering and download

The base64 string is converted to binary bytes, then wrapped in a Blob and turned into an object URL that the browser can display directly in an image element. For download, the same Blob is used to create a temporary link with a filename built from the detected format, such as image.png. All processing happens client-side, so the original string is never sent to a server.

Good uses

  • You have a base64 string embedded in a JSON API response and want to verify it actually decodes to a valid image before writing code to handle it.
  • You copied a data URI from browser developer tools or an email source and need to save the actual image file it contains.
  • You are testing a base64 encoder and want to visually confirm that the output string represents the correct image and hasn't been corrupted in transit.

Limits and checks

  • A base64 string with an unknown or malformed header may show a broken image or be labeled 'unknown format'; the tool cannot guess what the intended image type was.
  • Base64 without padding characters (common in some URL-safe encodings) may fail to decode; the tool expects standard base64 including trailing '=' padding where needed.
  • The displayed size and dimensions come from the decoded binary data itself, so a valid decode does not mean the image is safe or non-malicious, only that it is structurally a valid image.

Common questions

Can I paste a base64 string that doesn't have the 'data:image/...' prefix?

Yes. The tool attempts to decode any base64 string you enter. The prefix is optional because format detection primarily relies on the file signature in the first bytes of the decoded data. Without the prefix, the tool may still correctly identify the format from the signature.

Will this fix a base64 string that shows as broken in my HTML img tag?

No, not usually. If the string fails here, it will almost certainly fail in an img tag too, because both rely on the same decoding rules. Broken images are typically caused by truncation, wrong encoding, or copy-paste errors in the string itself. The tool can help you confirm that, but it cannot repair a damaged string.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools