Skip to content
Processing locally — files never leave your device

Image to Base64 Converter

Turn any image into a Base64 data URI you can paste straight into HTML, CSS, JSON, or an email template, and convert a Base64 string back into a downloadable image the other way. Inlining an image as Base64 saves an HTTP request, which is handy for small icons, email signatures, and self-contained pages. The file is read and encoded entirely in your browser, so the image never leaves your device.

How to use Image to Base64

  1. Pick a direction: "Image → Base64" to encode, or "Base64 → Image" to decode.
  2. To encode, drop or browse for an image — the data URI appears instantly with original and encoded sizes.
  3. Copy the full data URI with one click, ready to paste into HTML, CSS, or JSON.
  4. To decode, paste a Base64 string or a complete data URI into the text box and click Decode.
  5. Preview the decoded image, then download it as a real image file.

Image to Base64 and back, explained

Base64 encoding turns binary image data into plain text so it can travel inside formats that only accept characters — HTML, CSS, JSON, SVG, or a copy-and-paste email. This tool converts in both directions: it encodes any image into a ready-to-paste data URI, and decodes a Base64 string or data URI back into a downloadable image file.

How the conversion works

Encoding reads your file with the browser's FileReader API and returns a complete data:[mime];base64,… string, along with the original and encoded sizes so you can judge the overhead. Decoding parses the MIME type out of the data URI, rebuilds the raw bytes, and hands you a real Blob you can preview and save. Because every 3 bytes become 4 characters, the encoded text is always about a third larger than the source.

The size overhead, with real numbers

Base64 packs every 3 bytes of binary into 4 printable characters, so the text is always about 33% larger than the file it came from — a 1.5 KB icon becomes roughly 2 KB of string, a 40 KB photo becomes about 53 KB, and a 1 MB image balloons past 1.3 MB. On top of that comes the data-URI prefix itself (data:image/png;base64,is 22 characters) and, once it lands in HTML or CSS, that bloated payload sits in the markup uncompressed unless your server applies gzip or Brotli — which recovers some, but not all, of the penalty because Base64's restricted alphabet is less compressible than raw text.

When inlining helps

  • Tiny, critical icons— inlining a sub-2 KB logo or UI glyph removes an HTTP round-trip on first paint, and at that size the 33% penalty is a few hundred bytes you'll never notice.
  • Self-contained files — single-file HTML emails, exported reports, or SVGs that must carry their own raster artwork with no external dependencies.
  • Config and data payloads — slipping a small image into a JSON API response or a theme file where a separate request would be awkward.

When inlining hurts

The economics invert as the image grows. A hosted file is fetched once and then served from the browser cache on every later page; an inlined data URI is re-downloaded in full with the HTML or CSS every single time, because it has no independent cache entry. Inline a 200 KB hero image and you have added 260 KB to the render-blocking stylesheet that must arrive before the page can paint — the opposite of the latency win you got from a tiny icon. Large data URIs also bloat the DOM, make source files unreadable, and can't be lazy-loaded. The rule of thumb: inline assets in the low single-digit kilobytes, host everything else.

Everything runs in your browser

Both directions use plain browser APIs in this tab, so the tool keeps encoding and decoding on a plane or a locked-down network where an upload-based converter would simply fail.

Tips for clean results

  • Match the MIME prefix to the real image type, or some browsers silently refuse to render it.
  • Compress or resize before encoding — a smaller source means a far shorter string.
  • When pasting into CSS, keep the whole data URI on one line to avoid accidental whitespace breaks.

Related image tools

Frequently asked questions

When should I use a Base64 data URI for an image?
For very small assets — icons, sprites, or 1×1 tracking pixels under about 1–2 KB embedded directly in CSS or HTML. Inlining saves a separate HTTP request, which can shave latency on critical above-the-fold graphics. For anything larger, prefer a real file: Base64 inflates the byte size by roughly 33% and the inlined data cannot be cached separately by the browser.
Does the encoded string work in CSS and HTML?
Yes. In CSS use background-image: url(data:image/png;base64,…); in HTML use <img src="data:image/png;base64,…">. The MIME type at the start of the data URI must match the actual image type (image/png, image/jpeg, image/webp, image/svg+xml) or some browsers will refuse to render it.
What is a data URI, and how is it different from plain Base64?
Plain Base64 is just the binary image bytes re-encoded into a 64-character alphabet. A data URI wraps that string with a prefix — data:[mime];base64, — so the browser knows what kind of file it is. This tool outputs the full data URI when encoding, and accepts both a bare Base64 string and a complete data URI when decoding.
Why is the Base64 version larger than my original file?
Base64 represents every 3 bytes of binary data with 4 ASCII characters, so the encoded text is always about 33% bigger than the source image. That overhead is the trade-off for being able to embed binary data inside text-based formats like HTML, CSS, JSON, and SVG.
Does decoding preserve the original image format?
Yes. The MIME type carried in the data URI determines the output — a data:image/webp string decodes back to a WebP file, a data:image/jpeg string to a JPG, and so on. If you paste a bare Base64 string with no prefix, the tool assumes PNG.
Is there a size limit?
The practical limit is your browser tab’s memory. Small icons and logos encode instantly; multi-megabyte photos work too but produce very long strings that are awkward to handle in source files. For large images, a hosted file almost always beats an inline data URI.
Are my images uploaded to a server?
No. Encoding reads the file with the browser’s FileReader and decoding rebuilds the bytes in memory, so a private API key embedded in a config image or an unreleased asset is turned into text without that text ever being transmitted.

More tools you might find useful in the same flow.

Built by Muhammad Tahir · About