pythonware.com

Home / Image tools / Base64 to image

Encoding

Base64 to image

The other direction. Paste what you found in a stylesheet, an API response or an email source, and get a real file out.

Decoded

What the prefix tells you

A data URI starts with something like data:image/png;base64,. That prefix declares the type, and everything after the comma is the encoded bytes. If you paste the whole thing, the type is read from the prefix. If you paste only the encoded part, this page sniffs the first few bytes instead, which reliably identifies JPEG, PNG, GIF and WebP.

Base64 uses four characters for every three bytes, so an encoded image is about a third larger than the file it came from. Decoding gets that third back, which is why a data URI in a stylesheet is always heavier than linking the same image.

Common questions

It says the string is not valid. Why?

Usually because a line break or a stray quote came along with the copy, or because the string was truncated. Whitespace is stripped automatically; a missing tail cannot be.

Can it handle SVG?

Yes, if the data URI says image/svg+xml. SVG is text rather than binary, so it is sometimes URL encoded instead of Base64, in which case this will not decode it.

Other image tools