An html minifier not reducing base64 image size is almost always working as designed. A minifier removes markup overhead, such as extra whitespace and line breaks between tags. It does not resize, recompress or remove a photo that is encoded inside an src attribute as a data:image/jpeg;base64,... value, so that one long string can still make up most of the saved file.
The input here is an HTML export that contains a data URL image. The output you want is a file whose size reflects an optimized image, not just tidier tags. I use the HTML Minifier to compare the markup before and after, then inspect the image src in an editor, and fix the image itself instead of the markup. Keep a copy of the original export before you start.
Table of Contents

HTML Minifier Not Reducing Base64 Image Size: What Is Happening
A data URL puts a file’s bytes directly into a URL. RFC 2397, published in August 1998, defines the form: the data: scheme, a media type, an optional ;base64 marker, a comma and then the data. The HTML Standard treats the src of an <img> element as a URL for an image resource, so a data URL is a valid value there.
Base64 exists so binary bytes can travel as text. RFC 4648, published in October 2006, describes how every three input bytes become four output characters. That is the source of the overhead: roughly one third more text than the original image bytes, plus a short prefix and any padding. MDN’s data URL reference explains the same format, and I checked it on November 7, 2026.
A minifier works on the text structure of the document. An attribute value is just a string that it must keep intact, because changing a single character would corrupt the image. Here is a deliberately truncated example. It is not a real image, and a real one would run for thousands of characters:
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ..." alt="Office entrance with glass doors" width="800" height="450">
Minification can shrink the whitespace around that tag. It cannot touch the long value after the comma without breaking the picture. That is why a file can stay huge after you minify it.

HTML Minifier Not Reducing Base64 Image Size? Run This Diagnosis
You can confirm the cause in a few minutes. The goal is to compare numbers, not to guess from how the file feels.
- Save a copy of the original export under a new name and leave the original untouched.
- Note its size in bytes. Your file manager’s properties dialog works, and so does
wc -cin a terminal. - Open the HTML Minifier, paste the HTML, click minify, then copy or download the result.
- Compare the byte size of the minified output with the original. A small drop with a file that is still large means the markup was never the main cost.
- Paste the original into the HTML Code Editor and look at the
<img>tags. Syntax highlighting makes a very long attribute value easy to spot. You are looking fordata:imageand;base64,inside ansrcvalue. - Use the sandboxed live preview to see which image that string produces.
If you prefer the terminal, these two commands only read your files:
wc -c export.html minified.html grep -o 'data:image/[a-z+.-]*;base64' export.html
The first command prints the byte count of each file. The second prints only the matching prefix of each embedded image, so you see how many data URLs exist without flooding the screen with payload text.
Be clear about what these steps prove. Neither tool measures the decoded size of the image, and neither compresses images. The comparison shows only that the text outside the data URL was a small part of the file. Also remember that the HTML Code Editor documents its Minify button as able to change significant whitespace or inline scripts, so keep the original and check the rendered result after any minify step.

How Much Does Base64 Add? A Worked Calculation
For an input of n bytes, the Base64 text length is 4 multiplied by the result of rounding n divided by 3 up to a whole number. The padding character = fills out the last group when n is not divisible by three. The table below is a calculation from that rule, not a measurement of a real export.
| Original bytes | Base64 characters | Note |
|---|---|---|
| 300,000 | 400,000 | Divisible by three, so no padding |
| 100 | 136 | One byte over a multiple of three, so two padding characters |
| 99 | 132 | Divisible by three, so no padding |
The prefix data:image/jpeg;base64, adds 23 more characters. A 300,000-byte JPEG would therefore appear as about 400,023 characters in the HTML source. Minifying the markup around it saves perhaps a few dozen bytes, which is a rounding error next to that string.
Keep two sizes apart. The saved HTML file contains the full Base64 text, so the overhead is real there. Network transfer size is a different matter. According to MDN’s guide to HTTP compression, which I checked on November 7, 2026, a server can compress a response using Content-Encoding without changing the file you saved. So do not promise yourself an exact one-third saving in transfer size when you remove the data URL.
Fix the Image Instead of the Markup
Once the data URL is confirmed as the cause, work on the image. The options below are in the order I would try them.
- Resize an oversized source. If the original is far larger than the size at which the page displays it, export a smaller version. Changing the
widthandheightattributes only changes the displayed size. The embedded bytes stay the same. - Match compression and format to the content. MDN’s image file type guide separates formats that suit photographs, which tolerate lossy compression, from formats better suited to sharp-edged graphics such as logos and line art.
- Regenerate the data URL from the optimized image. Use whatever tool you normally use to produce data URLs, then replace the old value in the
srcattribute. - Use a separate file when your destination allows it. Save the optimized image as a file and point
srcat its path. This makes the HTML file smaller, but the image bytes still count toward the page’s total resources.
A separate file looks like this, using a fictitious path:
<img src="images/office-entrance.jpg" alt="Office entrance with glass doors" width="800" height="450">
Whichever route you pick, keep meaningful alt text and confirm the image still loads. A data URL is still a reasonable choice when you need one self-contained file. In that case, optimizing the image is the only lever, because the text will always be about a third larger than the bytes it encodes.
Other Places Large Embedded Images Hide
If the src attributes do not explain the size, look elsewhere in the file. A srcset attribute can list several image URLs, and any of them can be a data URL. A <style> block or an inline style attribute can hold url(data:...) values for backgrounds. Scan for ;base64, across the whole document, not only inside image tags.
The same reasoning applies to the CSS Minifier: it works on stylesheet text, so I would not expect it to recompress an image inside a url(). Minifiers can also change meaning as well as size, as the guide on how a CSS minifier removes space before :focus shows, so compare the result with the source.
Large inline scripts are another common weight. For those, the dedicated JavaScript Minifier uses Terser, which is a real JavaScript minifier and a different transformation from the simple Minify shortcut in the editor.
If your file came from a visual editor and looks incomplete, the cause may be unrelated to size. The guide on a WYSIWYG HTML download missing doctype, head and body explains why an export can be a fragment instead of a full page.
Checklist to Confirm the File Is Actually Smaller
Use this short list each time an export feels too big. It keeps formatting, image size and verification separate.
- Record the file size in bytes before and after minification.
- Identify long data URLs by searching for
data:imageand;base64,insrc,srcsetand CSS. - Optimize the image itself: resize it, then pick suitable compression and format.
- Replace or regenerate the
srcvalue, or switch to a separate file if your destination supports assets. - Recheck the export: run the byte comparison again, open the preview and confirm the image still renders with its
alttext.
I would never treat minification as guaranteed to preserve behavior. Whitespace between inline elements and inside inline scripts can matter, so always keep the original source, compare the rendered result and only then publish the smaller version.
Frequently asked questions
Does minifying HTML ever shrink a base64 image?
No. A minifier can remove whitespace and other markup overhead around the tag, but the Base64 value inside src must stay identical or the image breaks. Only changing the image itself, then regenerating the data URL, reduces that part of the file.
Is Base64 always exactly one third larger?
Roughly. Every three bytes become four characters, so the text is about 4/3 of the original, plus a short prefix and possible padding. That describes the saved HTML text. Transfer size over a network can differ if the server compresses the response.
Can I fix the size by changing width and height attributes?
No. Those attributes affect how large the image is displayed, not how many bytes are embedded in the src value. To reduce the embedded bytes, resize or recompress the source image and regenerate the data URL.
Will a separate image file make my page lighter?
It makes the HTML file smaller, because the long string disappears from the markup. The browser still has to load the image, so the page’s total resources still include its bytes. Optimize the image either way.
Which image format should I use for a smaller result?
It depends on the content. MDN’s image type guide describes lossy compression as suitable for photographs and other formats as better for sharp-edged graphics such as logos. Test the visual result at the size where it will be displayed.
What if I must keep everything in one HTML file?
Then optimize the image before encoding it: resize it to the displayed dimensions, choose suitable compression, and regenerate the data URL. Accept that the text will remain about a third larger than the image bytes it represents.
How do I check that the minified page still looks right?
Keep the original, open both versions in the HTML Code Editor’s sandboxed live preview or in your browser, and compare them. Check spacing between inline elements, the image with its alt text, and any inline scripts.
Next steps
An html minifier not reducing base64 image size is a clue, not a bug: the bytes live in the image, not in the markup. Your next step is simple. Take the oversized export, record its byte size, find each data:image value, optimize or replace that image, then run the minifier again and compare the numbers. Keep the original file until the rendered page matches.
Related tools and resources on HTML Editor Online:
- HTML Minifier
- HTML Code Editor
- Why a CSS Minifier Removes Space Before :focus and Breaks .menu
- WYSIWYG HTML Download Missing Doctype, Head and Body: Why It Happens
