Why SVG files carry extra weight
An SVG is plain text, so anything the design tool writes into the file adds to its size. Exports from drawing software often include XML declarations, comments, generous indentation, line breaks and spacing around attributes. None of that changes how the picture looks, but all of it is counted in bytes.
Optimizing means removing the parts that browsers ignore. This tool applies a straightforward cleanup: it deletes comments, removes the XML declaration at the top, collapses runs of whitespace into a single space, removes spaces between tags, and tightens the spacing around equals signs before attribute values. The drawing instructions themselves are left alone.
When cleaning up an SVG helps
Small savings matter when an SVG is inlined into HTML, used for icons that load on every page, or sent through an email or CMS with size limits. Removing comments is also a good idea before publishing, since comments can reveal notes or tool names you did not intend to share.
For developers working with markup directly, the same cleanup is also available as SVG Optimizer for Developers. If you need a raster copy of the graphic afterward, use SVG to PNG.
Keep expectations realistic. Whitespace and comments are usually a small share of a file. Large savings come from simplifying paths or merging shapes, which this tool does not do.
How to optimize SVG markup
- Paste your SVG code into the SVG markup box. A small sample circle is loaded by default, so select it and replace it with your own code.
- The optimized version appears instantly in the second box. There is no button to press.
- Check the label above the result, which shows the size before and after as a count of characters formatted as bytes.
- Click Copy to put the cleaned code on your clipboard, or Download to save it as a file named
optimized.svg.
This tool works with pasted text, not uploaded files. If your SVG is in a file, open it in a text editor, copy everything and paste it in. Processing happens in your browser, so your markup is not sent anywhere.
Limits and cautions
The cleanup is deliberately simple and applies to the whole text. Collapsing whitespace also affects text inside tags, so if your SVG contains text elements where spacing matters, or preformatted content in a style block, compare the result visually before using it.
It does not merge or shorten paths, remove unused definitions, round numbers, drop hidden elements or rename ids. For deeper reduction, a build-time tool such as SVGO is the recommended partner, and the page itself says so.
Always test the output. Paste the optimized code into an HTML file or open the downloaded SVG in a browser, and confirm it looks identical. If the file was not valid before, cleaning it will not repair it. Keep your original copy in case you need to edit the artwork later.