Base64 Image Decoder and Encoder

Decode a Base64 string or data URL back into an image, or encode any image as Base64, directly in your browser. Nothing is uploaded.

Base64 to Image

Decoded preview appears here.

Image to Base64

Using Base64 images without regretting it

Base64 makes the data about a third bigger. Every three bytes of image become four characters of text, so a 30 KB image turns into roughly 40 KB of string. It also loses its own cache entry: the image travels inside whatever HTML, CSS or JSON carries it, and is downloaded again each time that file is.

Inline the small images, link the large ones. A tiny icon or a placeholder is a good fit, because it saves a request. A photograph is not. As a data URL it bloats the page, delays everything that comes after it in the HTML, and cannot be lazy-loaded. Resize and compress an image first, and if it is still more than a few kilobytes, serve it as a normal file.

Email is the usual trap. Several of the largest email clients, Gmail among them, do not reliably display images embedded as data URLs. For newsletters and transactional mail, host the image or attach it with a content ID instead.

A data URL and raw Base64 are not the same thing. The encoder returns a complete data URL, which starts with data:image/png;base64, followed by the data. An HTML src attribute or a CSS url() takes that whole string. Many APIs and JSON fields want only the part after the comma, so delete everything up to and including base64, before you paste it. The decoder accepts either form.

Common questions

How do I decode a Base64 string to an image?

Paste the Base64 text into the Base64 to Image box, with or without the data:image/...;base64, prefix, and press Decode. The picture appears below the box and Download saves it. Without the prefix the file is treated as a PNG, so it is saved as .png.

How do I use the result in HTML or CSS?

Paste the whole data URL into an image tag, as in img src="data:image/png;base64,...", or into a stylesheet, as in background-image: url("data:image/png;base64,..."). The string already contains the image type, so nothing else is needed.

Why does the decoder say my Base64 is invalid?

Usually the text was cut off when it was copied, or it picked up stray characters such as quotation marks or a trailing comma from a JSON file. The decoder accepts standard and URL-safe Base64, with or without the data: prefix, and ignores line breaks.

Is Base64 a way to hide or protect an image?

No. It is an encoding, not encryption, and anyone can decode it in seconds, including with this page. Do not rely on it for anything private.

Does encoding change the image?

No. The encoder converts the exact bytes of your file, and decoding returns an identical file. No quality is lost in either direction.

Which image formats work?

Any image your browser can open, including PNG, JPG, WEBP, GIF and SVG. The output keeps the original format and records it in the data URL.

Are my images uploaded anywhere?

No. The file is read by your browser and the Base64 text is built on your device. Nothing is sent to a server, and there is no account or upload step.

Supported formats

Supported input formats: PNG, JPG, WEBP, GIF, SVG

Supported output formats: Base64 data URL

Encoding is the right tool when an image has to travel as text: inside a JSON request, a CSS file, a config value or a single self-contained HTML page.

Decoding goes the other way. Paste a string from an API response or a log and see whether it is actually an image before you build anything around it.

If the result is larger than you expected, shrink the picture first. Base64 adds roughly a third to whatever size the file already has.

Related tools

Explore by category