Minify & Unminify SVG Online — Free SVG Optimizer
Minify and unminify your SVG code instantly to reduce your file sizes and improve your website performance. Our free online SVG optimizer removes unnecessary whitespace, comments, metadata and optimizes structure while preserving all SVG functionality. Instant and secure processing, no registration required.
Loading...
SVG Minification
Compressing SVG files by removing whitespace, comments, metadata and unnecessary characters while preserving all SVG functionality
Basic example
Input SVG
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<circle cx="50" cy="50" r="40" fill="blue"/>
<rect x="20" y="20" width="60" height="60" fill="red"/>
</svg>
Minified SVG
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="blue"/><rect x="20" y="20" width="60" height="60" fill="red"/></svg>
Minification options
Remove Comments
Removes all SVG comments (<!-- ... -->) from code
Comparison with/without option:
Original code
<svg>
<!-- This is a comment -->
<circle cx="50" cy="50" r="40"/>
</svg>
With removeComments: true
<svg><circle cx="50" cy="50" r="40"/></svg>
With removeComments: false
<svg><!-- This is a comment --><circle cx="50" cy="50" r="40"/></svg>
Collapse Whitespace
Collapses multiple whitespace characters into single spaces
Comparison with/without option:
Original code
<svg>
<text> Multiple spaces </text>
<g> Group </g>
</svg>
With collapseWhitespace: true
<svg><text> Multiple spaces </text><g> Group </g></svg>
With collapseWhitespace: false
<svg><text> Multiple spaces </text><g> Group </g></svg>
Remove Metadata
Removes metadata elements from SVG code
Comparison with/without option:
Original code
<svg>
<metadata>Some metadata</metadata>
<circle cx="50" cy="50" r="40"/>
</svg>
With removeMetadata: true
<svg><circle cx="50" cy="50" r="40"/></svg>
With removeMetadata: false
<svg><metadata>Some metadata</metadata><circle cx="50" cy="50" r="40"/></svg>
Remove Empty Attributes
Removes attributes with empty values
Comparison with/without option:
Original code
<svg>
<circle cx="50" cy="50" r="40" id="" class=""/>
</svg>
With removeEmptyAttributes: true
<svg><circle cx="50" cy="50" r="40"/></svg>
With removeEmptyAttributes: false
<svg><circle cx="50" cy="50" r="40" id="" class=""/></svg>
Remove Hidden Elements
Removes elements with display:none or visibility:hidden styles
Comparison with/without option:
Original code
<svg>
<circle cx="50" cy="50" r="40" style="display:none"/>
<rect x="10" y="10" width="20" height="20" style="visibility:hidden"/>
</svg>
With removeHiddenElements: true
<svg></svg>
With removeHiddenElements: false
<svg><circle cx="50" cy="50" r="40" style="display:none"/><rect x="10" y="10" width="20" height="20" style="visibility:hidden"/></svg>