Image Compressor
Shrink JPG, PNG and WebP with a quality slider and live size readout.
Image & Photo
Data URIs for CSS and HTML, and decoding back.
Outside those, it is usually the wrong trade. Modern HTTP/2 and HTTP/3 multiplex requests, so the round-trip saving that justified data URIs a decade ago is much smaller than it was.
Base64 encodes three bytes as four characters, so the encoded form is about 33% larger than the file. Add the data URI prefix and it is a little more.
The bigger cost is caching. A separate image file is cached once and reused across every page. An inlined one is part of the HTML or CSS, so it is transferred again on every page that contains it and cannot be cached independently.
For a 40 KB image inlined into a stylesheet loaded on fifty pages, the arithmetic is comprehensively against you. That is the case worth checking before inlining anything above a couple of kilobytes.
For SVG, URL-encoding rather than Base64 produces a smaller result — SVG is text, so Base64 inflates it needlessly while percent-encoding leaves most characters as they are.
Better still, inline the SVG markup directly in the HTML, which allows CSS to style it.
Base64 for SVG is one of the most common avoidable size mistakes in front-end code, and it also throws away the ability to change the icon colour from CSS.
For icons under about 2 KB, critical above-the-fold images, single-file deliverables like HTML email, and offline documents. Outside those the caching loss usually outweighs the saved request.
About 33%, since three bytes become four characters, plus the URI prefix. The larger cost is usually caching rather than size.
An inlined image is part of the HTML or CSS, so it is re-transferred on every page containing it and cannot be cached separately. A normal image file is fetched once and reused everywhere.
No. SVG is text, so Base64 inflates it needlessly. Percent-encoding is smaller, and inlining the markup directly is better still because CSS can then style it.
Browsers handle multi-megabyte data URIs, but you should not. Past a few kilobytes the caching and transfer costs make a normal image file the better choice.