DevTools Pro · All tools · About

Base64 Image Converter

About the Base64 Image Converter

This Base64 image converter turns any PNG, JPEG, GIF, WebP, AVIF, BMP, ICO or SVG file into a Base64 string or data URI, and decodes Base64 back into an image you can preview and download. It also produces ready-to-paste HTML <img> and CSS background-image snippets.

What is a Base64 data URI?

A data URI embeds a file directly inside a URL instead of pointing to it. For images it looks like data:image/png;base64,iVBORw0KGgo...: the scheme, the MIME type, the ;base64 flag, a comma, then the encoded bytes.

Browsers treat it like any other image source, so it works in <img src>, CSS url(), inline SVG and JavaScript. The image loads with the document and needs no extra HTTP request.

Why is Base64 about 33% bigger?

Base64 represents every 3 bytes of binary data with 4 ASCII characters, so the encoded text is roughly 4/3 the size of the original file plus a little padding. A 30 KB PNG becomes about 40 KB of text. The tool shows this overhead next to each encoded image.

Gzip or Brotli on your server claws back part of that, but inlined images also cannot be cached separately from the HTML or CSS file that contains them.

When to inline images (and when not to)

Inlining makes sense for small, frequently used assets: icons under a few kilobytes, tiny background patterns, placeholders, and images inside HTML emails or single-file demos where external files are inconvenient.

For photos and anything larger than about 10 KB, a normal image file is usually better. It can be cached, lazy-loaded and served in modern formats, and it does not block the parsing of the stylesheet or page that embeds it.

How the format is detected

When decoding, the tool ignores the declared MIME type when it can and reads the first bytes instead. PNG starts with 89 50 4E 47, JPEG with FF D8 FF, GIF with GIF8, and WebP with RIFF....WEBP. That way a mislabeled data URI still downloads with the correct extension.

URL-safe Base64 (using - and _) and pasted line breaks are accepted, and a missing = padding is fixed automatically.

How to Use the Base64 Image Converter

  1. To encode, open the Image → Base64 tab and click the upload area or drop an image onto it (up to 10 MB).
  2. Review the preview, MIME type, dimensions and Base64 size overhead.
  3. Click Copy next to Data URI, Base64 only, HTML <img> or CSS background, depending on where you will paste it.
  4. To decode, switch to Base64 → Image, paste a data URI or raw Base64 text, and click Decode image.
  5. Check the decoded preview and click Download to save it with the detected file extension.

Frequently Asked Questions

Is my image uploaded when I convert it?
No. Files are read with the FileReader API and decoded with atob in your browser. Nothing is sent to a server.
What is the maximum file size?
Images up to 10 MB can be encoded. In practice, Base64 is only worth using for small files of a few kilobytes.
What is the difference between "Data URI" and "Base64 only"?
The data URI includes the data:image/...;base64, prefix and works directly as an image source. Base64 only is the bare encoded text, which APIs and JSON fields often expect.
Why does my Base64 string fail to decode?
Common causes are a truncated copy, stray characters such as quotes, or = padding in the middle. The error message shows which problem was found and where.
Can I convert SVG to Base64?
Yes. SVGs are detected and encoded as image/svg+xml. For SVG specifically, a URL-encoded data URI is often a little smaller than Base64.
Does Base64 encoding compress or change the image?
No. It is a lossless text representation of the exact same bytes, just about a third larger.

Related tools