Cut SVG file size by 66%+ with SVG Cleaner
Scalable Vector Graphics is a powerful image format with support for scripting, filters, animation, interactivity and more. But it’s also XML-based, and not exactly efficient: SVG file sizes can be much larger than you expect, an issue if you’re putting them online.
SVG Cleaner is an open source tool which optimizes SVG images, stripping out unnecessary elements and attributes, compressing whatever’s left, and usually making a real difference to their file size.
This process can be extremely simple. Point the program at a folder tree, choose an Output folder, and click "Start". SVG Cleaner then locates any SVG images, cleans them up, and saves the results: easy.
If you need more control, though, there are plenty of options available. You’re able to point the program at specific SVG files. You can choose exactly which elements and attributes to remove, the optimizations and path tweaks to apply. And the cleaned files can be saved in the same folder as the originals, even overwriting them if that’s what you need.
The developer claims this process can cut file sizes by 10-60 percent. As a check, we grabbed 24 sample SVG’s from the W3C site, passed them through SVG Cleaner, and saw our original 2.75MB of data drop to 965KB -- an even more impressive 65 percent saving. This won’t be typical (the source files weren’t optimized at all, and we intentionally chose large images), but it does show that individual savings of 60 percent or so are very possible.
It’s vital that this compression doesn’t affect the image, of course, and to reassure you SVG Cleaner displays "before" and "after" thumbnails for every processed file. If there are any obvious differences then hovering your mouse cursor over that thumbnail will display a larger version.
This isn’t really enough to validate some images, unfortunately. SVG Cleaner’s developer points out that its internal viewer doesn’t display a whole range of advanced SVG features -- clipPath, mask, filters -- and of course you can’t check animation from the program’s static thumbnails. If you want to compress your images then you’ll need to check each one afterwards to confirm it still looks and works as you expect.
The savings you could make are considerable, though, and if you really need your SVG’s to be as small as possible, SVG Cleaner can do a lot to help.