Base64 to Image

Decode a Base64 string and preview the image.

Preview

Local Your input is rendered locally in your browser. Found a problem? Report an issue

What Base64 to Image does

Base64 to Image decodes a Base64 string or a data URI and shows the image. It recognises PNG, JPEG, GIF, WebP and SVG from the first bytes, so you can paste a raw Base64 string without the data: prefix.

Using Base64 to Image

  • The preview is redrawn as you type.

How it works

If the input already starts with data:, it is used as-is. Otherwise the first characters identify the format: iVBOR is PNG, /9j/ JPEG, R0lGOD GIF, UklGR WebP, and PHN2Zy or PD94bW SVG. The image is shown inside a sandboxed frame with no script permission.

Details and limits

  • There is no fixed size limit: everything runs on your device, so very large inputs depend on its memory.
  • It works in current browsers on phones, tablets and computers, and it is free with no account needed.
  • Encoding and decoding are exact, so the data comes back without losing anything.
  • When the type cannot be recognised from the first characters, the data is treated as PNG.
  • Line breaks and spaces in the Base64 text are removed before decoding.
  • An SVG is drawn as an image, so scripts and external references inside it are not executed or loaded.
  • There is no download button. To save the picture, use your browser's own "save image" command on the preview.
  • Input that is not valid Base64 stops the tool, and the status line shows where the problem is. The Base64 to JSON page lists the usual causes.

Worked example: Decoding a data URI 1×1 transparent PNG pixel

Web developers often embed tiny placeholder graphics or SVG icons directly inside CSS or HTML using a Base64 data URI. Paste this complete string (or just the part after base64,) into the input box:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
  • Magic-byte header detection: The first 8 Base64 characters iVBORw0K decode to the hexadecimal bytes 89 50 4E 47 0D 0A 1A 0A, which is the official PNG file signature.
  • Decoded dimensions and size: The IHDR chunk immediately after the signature specifies a width of 1 px, height of 1 px, 8-bit RGBA color, and a total binary file size of 68 bytes, ready to preview and download as image.png.

Limits and what this tool cannot do

  • Only browser-supported web image formats render: The decoder identifies and previews PNG (starts with iVBOR), JPEG (starts with /9j/), GIF (starts with R0lGOD), WebP (starts with UklGR), and SVG (starts with PHN2Zy or PD94bW). Base64 strings representing PDFs, ZIP archives, or TIFF/PSD files will not render as an <img> preview.
  • Truncated Base64 strings from console logs: Developer tools network panels and server logs sometimes truncate long strings with ... in the middle. If the end of the Base64 string is cut off, the bottom of a JPEG will appear gray or a PNG will fail its CRC checksum.

Questions

Which image formats are recognised?

PNG, JPEG, GIF, WebP and SVG are recognised from the first characters of the Base64 text. Any other data is labelled as PNG, and the browser shows a broken image if it cannot draw it.

How can I tell what image format a Base64 string is just by looking at the first few letters?

Every file format starts with fixed magic bytes: iVBORw0KGgo is always a PNG, /9j/ is always a JPEG, R0lGODlh or R0lGODdh is a GIF, and UklGR is a RIFF WebP image.

Do I need to strip 'data:image/png;base64,' before pasting?

No. The tool automatically strips any leading data:image/...;base64, prefix, surrounding CSS url(...) quotes, and line breaks before decoding.

Why is embedding large images as Base64 in HTML or CSS discouraged?

Base64 adds ~33% to the image's byte size and prevents the browser from caching the image separately from the HTML or CSS stylesheet. Keep Base64 data URIs for tiny icons under 2–4 KB.