Image to Base64

Choose an image to get a Data URI and plain Base64 with the size change, or paste Base64 to preview the image and download it.

Image to Base64

Or drop an image here. It's read in your browser and never uploaded, compressed, or resized.

Base64 to Image

Paste something and the image preview appears here, ready to download.

How to Use

  1. Press “Choose an image” to pick one from your computer or phone photo library, or drag an image into the box. It's read only in your browser, never uploaded, compressed, or resized.
  2. You get a preview with the original and encoded sizes, then two results: “Data URI” starts with data:image/…;base64, and goes straight into a CSS url() or an HTML img src; “Plain Base64” has no prefix and is for APIs or code. Press “Copy” on either.
  3. To go the other way, paste a Data URI or plain Base64 into the “Data URI or Base64” box. Missing = and line breaks are fine, and the URL-safe alphabet works too. The image type is detected from the start of the data, not from the type declared after data:. Once the preview shows, press “Download image” to save it.
  4. PNG, JPEG, GIF, WebP, AVIF, BMP, ICO, and SVG are supported. If what you paste can't be recognized as an image, you're told why, such as a character outside the Base64 alphabet, bad padding, or decoded data that isn't an image.

Image to Base64: Input and Output

Choose an image, or drop one into the box, and you get a Data URI and plain Base64 side by side. Here is a real example with a tiny image, a 1×1 pixel GIF.

Field Value
Original size 42 bytes
Encoded size 56 characters
Plain Base64 R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
Data URI data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7

The Data URI is the plain Base64 with data:image/gif;base64, in front. Put the Data URI into an HTML image tag or a CSS url(), for example background-image: url("data:image/gif;base64,R0lGOD…"). Use the plain Base64 for an API field or code that builds its own string.

To go the other way, paste the Data URI or the plain Base64 into the second box. The page detects that it is a GIF, shows a preview, and lets you download it.

When Inlining an Image Makes Sense

Base64 uses 4 characters for every 3 bytes, so the text is about a third larger than the image. In the example, 42 bytes became 56 characters. For a tiny icon, that is a fair trade for one less network request. For a large photo it makes your CSS or HTML heavy, and the image can no longer be cached on its own.

Nothing is compressed or resized. The image is read in your browser and is not uploaded.

FAQ

How do I turn an image into a Base64 string?

Press “Choose an image” or drop a file into the box. You get two results at once: a Data URI that starts with data:image/…;base64, and the plain Base64 without that prefix. Press “Copy” on the one you need. The page shows the original size and the encoded size, and nothing is compressed or resized.

Can I convert Base64 back to an image?

Yes. Paste a Data URI or plain Base64 into the “Data URI or Base64” box. The image type is detected from the data itself, a preview appears, and “Download image” saves it. If what you pasted isn't an image, you're told what is wrong.

Is my image uploaded to a server?

No. An image you choose or drop is read and converted only in your browser and never sent to a server, and pasted Base64 is parsed and previewed in your browser too. Neither the image nor what you paste is saved on this device, so the next person on a shared computer won't see them.

Is Base64 encryption? Can others see my image?

Base64 is encoding, not encryption. It only rewrites the image's bytes as text. There's no key and no secrecy, so anyone holding that text can turn it back into the same image. To protect content use encryption such as AES, and don't treat Base64 as a way to keep anything private.

Why is the Base64 larger than the original image?

Base64 uses 4 characters for every 3 bytes, so the result is about 4/3 of the original, roughly 33% larger. The page shows the original and encoded sizes side by side. Inlining a small icon of a KB or two saves a network request, but inlining a big image bloats your CSS or HTML and stops it being cached on its own, which usually isn't worth it.

What's the difference between a Data URI and plain Base64?

A Data URI is data:image/png;base64, followed by the plain Base64. Browsers understand it, so it goes straight into a CSS url() or an HTML img src. Plain Base64 is just the data with no type information, which suits an API field or code that builds its own string, where you add the type yourself. Use a Data URI for a web page and plain Base64 to send to a backend.

What if it says the data isn't a recognizable image format?

The format is judged from the start of the decoded data. The most common cause is that what you pasted isn't an image, or that it was cut off or is missing a part. It could also be a format browsers can't display, such as TIFF or HEIC, which isn't supported. A Data URI with no ;base64 after its type holds percent-encoded text, which isn't supported either.

Which image formats are supported, and is there a size limit?

PNG, JPEG, GIF, WebP, AVIF, BMP, ICO, and SVG. The tool sets no size limit, but the output text is a third larger than the image, and with a very large image the browser gets slow to process and copy it. Keeping inlined images to a few dozen KB is a good rule.