Image to Base64

Encode images into data URIs, or paste a data URI and get the image back. Both directions, in your browser, with no server in the middle.

Drop images here

or click to browse — batch supported

Results are produced locally. Nothing is uploaded.

Base64: what it is, and the 33% tax nobody mentions

A data URI is a way of putting a file inside a document instead of linking to it. The syntax is short: data:image/png;base64, followed by the file's bytes translated into Base64.

The 33% is not a rounding error

Base64 represents 3 bytes of binary data using 4 ASCII characters. That is a fixed, unavoidable 33% size increase before any other consideration. A 100 KB JPEG becomes roughly 137 KB of text.

Compare that to what actually happens on the network: your server is almost certainly already serving images with gzip or Brotli, but Base64 text compresses far worse than the equivalent well-chosen binary format. A modern image format is already entropy-coded; re-encoding it as text and then compressing the text recovers much less than people assume.

So the honest framing is: Base64 costs you about a third in raw size, and you are paying it to buy something else. Make sure the thing you are buying is worth it.

When it genuinely is worth it

  • Eliminating a request for a critical tiny asset. An above-the-fold SVG sprite or a 1 KB logo, inlined, removes a round trip. On high-latency mobile connections a round trip can cost more than 300 bytes ever will.
  • Single-file delivery. Email templates, offline HTML documents, a self-contained demo you want to hand over as one file, a QR-code-encoded page. If there is no server, there is nothing to link to.
  • CSS-generated decoration. Small background textures and icon glyphs inside a stylesheet, where a URL would otherwise be resolved relative to the stylesheet's location and cause a surprising 404.

When it is a mistake

  • Anything above a few kilobytes. The payload is now inside your HTML, which means it is re-downloaded on every page that includes it, it cannot be cached independently, and — critically — it blocks. Browsers discover inlined images only after parsing the markup; they discover <img src> during preload scanning. Large inline assets delay that discovery.
  • Photographs, full stop. Run them through a proper encoder first. If you are reaching for Base64 on a photo, the underlying problem is usually that the photo is unoptimised, not that it is external.
  • Anything you hope to cache. An inlined asset lives and dies with the document. Change one word on the page and the user re-downloads every inlined image with it.

Where people get confused

Base64 is not compression. This is the most common misconception by a wide margin. "I base64'd my images to make them smaller" is never true — the output is always larger than the input. If you want smaller, you want a better encoder (WebP or AVIF) or a smaller dimension, not a different text encoding.

Data URIs are not private. Every character is plainly visible in the page source. Obscurity is not encryption; if an image is sensitive, Base64 gives you no protection at all.

Not every data URI is Base64. data:image/svg+xml, followed by URL-encoded SVG is a real and often better option — SVG is already text, so percent-encoding it is dramatically more efficient than Base64-encoding it, and the result stays human-readable and gzip-friendly.

A rule of thumb that survives contact with reality

Inline when the asset is small enough that the request overhead dominates — think single-digit kilobytes — and when it appears on pages where avoiding a round trip actually matters. Keep everything else as a separate, cacheable, properly encoded file. The exact crossover depends on your audience's latency and your cache headers, so treat it as a starting hypothesis and measure rather than a law.

Frequently asked questions

Why did my file get bigger?
Because Base64 always makes files bigger — typically by about a third. It is an encoding, not a compression method. If your goal was a smaller image, use an image compressor or convert to WebP or AVIF instead.
What is the maximum size I can encode?
There is no limit imposed by this tool; the practical limit is your browser's memory. Be aware that extremely long strings can be slow to paste into an editor and that many web servers and CDNs impose their own limits on document size.
Can I decode a data URI back into a file?
Yes — switch to decode mode and paste the whole data URI, including the data:image/png;base64, prefix. The tool reads the declared MIME type, decodes the payload and gives you the image back as a downloadable file.
Does this work with SVG?
It does, but for SVG you will usually get a much smaller result by URL-encoding the markup rather than Base64-encoding it, since SVG source is already text. Consider minifying the SVG first — see the SVG Minifier.
Is a data URI secure?
It provides no confidentiality whatsoever — the content is trivially decodable by anyone who can read the source. There is also a content-injection consideration: never build a data URI from user-supplied input and assign it to src or href without validating the MIME type, since data:text/html URIs can carry script.