ToolNimba

πŸ–ΌοΈ Base64 to Image Converter: Decode Base64 and Data URIs

By ToolNimba Web Dev Team Β· Updated 2026-06-25

Accepts a full data URI or a bare Base64 string. The data is decoded in your browser and never leaves your device.

Paste a Base64 image string and press Render image.

This Base64 to image converter turns a Base64 string or a full data URI back into a real, viewable image. Paste the text, and the tool decodes it, shows a live preview, works out the image type, and gives you a download link. If only the raw Base64 part is supplied, you can pick or auto-detect the MIME type. Everything runs in your browser, so the data is never uploaded to a server.

What is the Base64 to Image?

Base64 is a way of writing binary data, such as an image file, using only 64 plain text characters (A to Z, a to z, 0 to 9, plus + and /). Because it is text, a Base64 image can be embedded directly inside HTML, CSS, JSON or an email instead of being stored as a separate file. Decoding reverses that process: it reads the text back into the original bytes so a browser can display the picture again. Encoding and decoding are exact inverses, so a clean round trip always reproduces the original image pixel for pixel, with no quality loss.

Most Base64 images travel as a data URI, which looks like data:image/png;base64,iVBORw0KGgo and so on. The part before the comma is a header that names the MIME type (here image/png) and states that the payload is Base64 encoded. The part after the comma is the actual encoded image. This tool reads that header when it is present, so it knows the exact type without guessing. When you paste only the raw Base64 with no data: prefix, there is no header to read, so the type is inferred from the first few bytes, the magic number, or you can set it yourself from the MIME type list.

Decoding happens entirely on your device using the browser's built-in atob function and a Blob, which is then loaded as an image to confirm it is genuinely decodable. Because nothing is sent over the network, even large or private images stay local, which makes this safe for internal database strings, screenshots from tickets, or proprietary design assets. The tool also reports the decoded byte size and the pixel dimensions once the image renders, so you can verify the file is what you expected.

The encoding follows the RFC 4648 standard alphabet. Every four Base64 characters map back to three original bytes, and one or two trailing = characters pad the final group when the source length is not an exact multiple of three. This is why Base64 text is always about one third larger than the binary it represents. A useful side effect is that the first few characters of a Base64 image often reveal its format at a glance: a string starting with iVBOR is a PNG, /9j/ is a JPEG, R0lGOD is a GIF, and PHN2Zy or PD94 usually signals SVG or XML.

Data URIs are popular because they cut a network request: a small icon, logo or sprite can live inline in a stylesheet or HTML page rather than as a separate download. The trade off is the one third size penalty and the fact that inline data is harder to cache than a standalone file. For tiny assets under a few kilobytes, inlining is often a net win; for larger images, a normal file with its own URL is usually faster. Decoding back to a real file, which this tool does, lets you switch from an inline data URI to a cacheable asset whenever that trade off no longer favours inlining.

If decoding fails, the cause is almost always the input rather than the image itself. Valid Base64 contains only the 64 alphabet characters plus optional = padding, and its length must be a multiple of four. Whitespace, line breaks copied from a code editor, a URL safe variant that uses - and _ instead of + and /, or a truncated copy will all break the decode. The tool strips common whitespace and tolerates a missing data: header, but a genuinely incomplete or corrupted string cannot be recovered and will report an invalid input error.

When to use it

  • Recovering an image that a developer or designer pasted to you as a Base64 data URI in a chat, ticket or document.
  • Inspecting a Base64 image embedded in HTML, CSS or JSON to see what it actually looks like before using it.
  • Saving an icon, logo or sprite that a website stores inline as a data URI rather than as a downloadable file.
  • Debugging an API response or SVG that returns image data as a Base64 string and checking that it renders correctly.
  • Converting an inline data URI back into a real, cacheable image file when an asset has grown too large to keep embedded.
  • Extracting an image stored as Base64 text inside a database column, config file or environment variable so you can view it.

How to use the Base64 to Image

  1. Paste the Base64 string or the full data:image/...;base64,... URI into the text box.
  2. If you pasted only the raw Base64, leave the MIME type on Auto-detect or pick the correct format from the list.
  3. Press Render image to decode and preview it.
  4. Check the detected type, decoded byte size and pixel dimensions shown below the preview.
  5. Use the Download button to save the file with the correct extension, such as image.png or image.svg.

Formula & method

A data URI has the shape: data:[MIME type];base64,[Base64 payload]. Decoding reverses Base64: every 4 Base64 characters map back to 3 raw bytes, so decoded size is about (Base64 length x 3) / 4 bytes, minus any padding (=).

Worked examples

You receive the full data URI data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg== and want the PNG.

  1. The header data:image/png;base64 tells the tool the type is image/png and the payload is Base64.
  2. The text after the comma is decoded from Base64 back to the original PNG bytes.
  3. The bytes are wrapped in a Blob of type image/png and loaded to confirm they form a valid image.
  4. A 1 x 1 pixel PNG appears in the preview with a Download button set to image.png.

Result: A valid 1 x 1 px PNG is previewed and ready to download as image.png

You paste only the raw Base64 R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 with no data: prefix.

  1. There is no header, so the MIME type cannot be read from the string.
  2. With Auto-detect on, the leading characters R0lGOD are recognised as the GIF magic number.
  3. The type is set to image/gif and the bytes are decoded and previewed.
  4. The download filename is set to image.gif based on the detected type.

Result: The raw Base64 is identified as a GIF and saved as image.gif

You copy a long Base64 string from a JSON API response and the tool reports it is invalid.

  1. You check the start of the string and see it begins with /9j/, which marks a JPEG payload.
  2. You notice line breaks and spaces were copied along with the text from the code viewer.
  3. You remove the stray whitespace so only the continuous Base64 characters remain.
  4. You confirm the final length is a multiple of four, with = padding kept intact, then press Render image.

Result: The cleaned string decodes correctly and the JPEG previews, ready to download as image.jpg

Common image MIME types and the magic bytes used to auto-detect them

MIME typeFile extensionLeading bytes (hex)
image/png.png89 50 4E 47
image/jpeg.jpgFF D8 FF
image/gif.gif47 49 46 38 (GIF8)
image/webp.webp52 49 46 46 ... 57 45 42 50 (RIFF...WEBP)
image/bmp.bmp42 4D (BM)
image/x-icon.ico00 00 01 00
image/svg+xml.svgtext starting with (less-than)svg or an XML prolog

Quick format guess from the first characters of a Base64 string (no header needed)

Base64 starts withLikely formatNotes
iVBORw0KGgoPNGMost common for screenshots and icons with transparency.
/9j/JPEGTypical for photos and lossy compressed images.
R0lGODGIFUsed for simple animations and small graphics.
UklGRWebPModern format, smaller files than PNG or JPEG.
QkBMPUncompressed bitmap, large file size.
PHN2Zy or PD94SVGText based vector format, often starts with an XML or svg tag.

How Base64 length relates to decoded image size

Base64 text lengthApprox decoded sizeRule of thumb
1,000 charsabout 750 bytesDecoded is roughly 3/4 of the text length.
12 KB data URIabout 9 KB imageBase64 adds about one third overhead.
100 KB stringabout 75 KB imageLong string does not mean a large picture.
1 MB stringabout 750 KB imageConsider a normal file over an inline data URI here.

Common mistakes to avoid

  • Copying only part of the Base64 string. A truncated string decodes to corrupt bytes and will not render, or shows a broken image. Make sure you copy the entire payload, including the trailing = padding if it is there.
  • Including the data: header inside the raw field but breaking it. If you paste a data URI, keep the whole thing intact (data:image/png;base64, and then the payload). Pasting the header without the ;base64 marker, or splitting it across lines incorrectly, stops it being recognised.
  • Expecting the type to be guessed for raw Base64. Without a data: header the type can only be sniffed from the bytes. For unusual formats, set the MIME type manually instead of relying on Auto-detect.
  • Confusing Base64 size with image size. The Base64 text is about one third larger than the real image. A long string does not mean a large picture, the decoded byte size shown after rendering is the true file size.
  • Leaving in line breaks or spaces from a code editor. Copying from a wrapped JSON or HTML viewer often drags in newlines and spaces. These extra characters can break the decode, so paste the continuous string and let the tool strip whitespace, or clean it yourself first.
  • Pasting URL safe Base64 by mistake. Some systems use a URL safe alphabet with - and _ instead of + and /. If a valid looking string still fails, swap those characters back before decoding, since the standard decoder expects + and /.

Glossary

Base64
A text encoding that represents binary data using 64 printable characters, letting images travel as plain text.
Data URI
A string of the form data:[MIME type];base64,[payload] that embeds a file inline instead of linking to it.
MIME type
A label like image/png or image/jpeg that tells software what kind of file the data is.
Magic number
The first few bytes of a file that identify its format, used here to auto-detect the image type.
Blob
A browser object holding raw binary data with a type, used to build a downloadable file from the decoded bytes.
Padding
One or two = characters at the end of a Base64 string that fill the final group when the data length is not a multiple of three.
atob
The browser function that decodes a Base64 string back into its original binary characters.
URL safe Base64
A Base64 variant that replaces + and / with - and _ so the text is safe to use inside URLs.

Frequently asked questions

How do I convert a Base64 string to an image?

Paste the Base64 string or the full data URI into the box and press Render image. The tool decodes the text, shows a preview, detects the image type, and gives you a download link. It all happens in your browser, so nothing is uploaded.

Do I need the data:image part, or just the Base64?

Either works. If you paste a full data URI like data:image/png;base64, and the payload, the type is read from the header. If you paste only the raw Base64, the tool auto-detects the type from the bytes, or you can choose it from the dropdown.

Is my image uploaded anywhere?

No. Decoding uses your browser only, with the built-in atob function and a local Blob. Nothing is sent to a server, so even private or large images stay entirely on your device, which makes it safe for internal or proprietary assets.

Why does it say the Base64 is invalid?

Valid Base64 uses only A to Z, a to z, 0 to 9, + and /, with optional = padding, and its length must be a multiple of four. Stray characters, copied line breaks, a URL safe variant using - and _, a truncated copy, or missing padding will trigger the error. Recopy the complete string and remove any whitespace.

Which image formats are supported?

PNG, JPEG, GIF, WebP, BMP, ICO and SVG are all supported. The type is taken from the data URI header, sniffed from the leading bytes, or set manually using the MIME type dropdown.

Can I decode a Base64 SVG?

Yes. Paste the data URI or raw Base64 for the SVG and it will render and download as a .svg file. SVG is detected by spotting an svg tag near the start of the decoded text, or you can select image/svg+xml manually.

How can I tell the image format just from the Base64 text?

The first few characters give it away. A string starting with iVBOR is a PNG, /9j/ is a JPEG, R0lGOD is a GIF, UklGR is WebP, and PHN2Zy or PD94 usually means SVG or XML. The reference table above lists these prefixes.

Why is the Base64 longer than the original image file?

Base64 represents three bytes of binary using four text characters, so the encoded text is always about one third larger than the file it came from. The decoded byte size shown after rendering is the true image size, not the text length.

Can I convert Base64 back to a JPG or PNG specifically?

Yes. If the data URI header or the magic bytes identify the format, the download is saved with the matching extension automatically. If you paste raw Base64 of an unusual file, pick image/jpeg or image/png from the dropdown to force the output type.

Should I use a Base64 data URI or a normal image file?

Inline data URIs avoid an extra network request, which suits tiny icons and sprites under a few kilobytes. For larger images, a normal file with its own URL is usually faster because it can be cached and does not carry the one third size penalty. Decoding here lets you switch an inline asset back to a real file when inlining no longer helps.