About the SVG Optimizer
The SVG Optimizer cleans up SVG markup by removing comments and collapsing unnecessary whitespace, then renders a preview so you can confirm the graphic still looks right. It is a quick tidy-up for icons and illustrations you plan to inline in HTML or ship on a website.
How it works
When you click Optimize SVG, the tool runs a series of text replacements: it deletes HTML-style comments, turns any run of whitespace into a single space, removes whitespace between > and <, after < and before >, removes spaces around = signs, and trims the ends. Attributes, paths and numbers are left exactly as they were.
That makes this a whitespace-and-comment minifier rather than a full optimizer like SVGO. It does not remove editor metadata elements, round path coordinates, merge shapes or drop unused definitions, so savings come mainly from formatting. The result is shown as code, rendered as an image, and offered as a downloadable file.
How to use
- 1
Open your SVG in a text editor and paste the code into the input box.
- 2
Click Optimize SVG.
- 3
Check the preview to make sure the graphic looks unchanged.
- 4
Copy the code from the output panel or click the download icon to save optimized.svg.
Worked examples
Exported icon with a comment
An icon exported from a design tool.
The comment, line breaks and indentation are removed: 145 characters become 114, a saving of 31 bytes (21%).
Frequently asked questions
Will optimizing change how my SVG looks?+
Normally not, because only comments and whitespace between tags and attributes are removed. Check the preview, especially for SVGs with <text> elements or inline CSS, where whitespace can matter.
Where does the extra data in an SVG usually come from?+
Design tools add generator comments, editor-specific metadata, IDs and indentation, and often write coordinates with many decimal places. This tool removes the comments and indentation; a full optimizer is needed for the rest.
How much smaller will my SVG get?+
For hand-formatted or pretty-printed files, typically 10 to 30 percent. Files where most of the size is path data will shrink less, because path coordinates are not changed.
Can I upload an SVG file?+
No, paste the code instead. Open the .svg file in any text editor to copy its contents.