Optimize SVG online, free
This SVG optimizer minifies SVG markup directly in your browser, without installing software or uploading your file anywhere. Paste your SVG, or upload an .svg file, click Optimize, and the tool runs it through two passes: a text-level pass that strips XML comments, collapses unnecessary whitespace between tags, and removes empty attributes, then a structural cleanup pass that parses the result and removes empty metadata blocks, editor-specific attributes such as Inkscape and Sodipodi markup, and empty groups with nothing in them. It shows you the before-and-after byte count so you can see exactly how much you saved.
This is a conservative, lossless optimizer: every transform it applies is safe by construction and never changes how the SVG renders. The structural cleanup pass only removes elements and attributes that have no effect on rendering, and it only runs when the file parses cleanly: if it doesn't, the tool quietly keeps the safe text-level result instead. It does not touch path data, does not simplify geometry, and does not round coordinates, all of which can shrink a file further but carry some risk of subtly changing the artwork if done carelessly. For that kind of aggressive optimization, use the full SVG Lab editor.
What gets removed
- XML comments:
<!-- ... -->blocks left behind by design tools carry no rendering weight and are removed entirely. - Whitespace between tags: the line breaks and indentation many editors insert between elements are collapsed, since they have no visual effect.
- Empty attributes: attributes left behind with an empty value, like
class="", are dropped. - Leading and trailing whitespace: any blank space at the very start or end of the file is trimmed.
- Metadata blocks:
<metadata>elements that some editors add, which have no effect on rendering, are removed. - Editor-specific attributes: namespaced attributes like
inkscape:labelorsodipodi:nodetypes, added by tools such as Inkscape, are stripped along with their namespace declarations. - Empty groups:
<g>elements left with no attributes and nothing inside them, including groups nested inside other empty groups, are removed.
The metadata, editor-attribute, and empty-group cleanup only runs after the file is confirmed to parse cleanly, and only when it produces a smaller result than the text-level pass alone. If your file is already compact, for example one exported from a tool that doesn't add editor cruft in the first place, there's less to strip, so expect the savings to be small.
Need to change the artwork itself, not just its file size? Open it in the full SVG Lab editor, or check its dimensions first with the SVG viewer.
Why minify an SVG
SVGs exported from design tools like Illustrator, Figma, or Sketch often carry a surprising amount of dead weight: editor metadata, XML comments describing layers, and formatting whitespace added purely for human readability. None of that affects how the file renders, but it does add up, especially for a site embedding dozens of icons, or an app inlining SVG markup directly into HTML where every byte is sent on every page load.
Minifying is one of the lowest-risk performance wins available for a file that's already correct: it changes nothing visually, so there's no need to re-check the artwork afterward. If you're also trying to reduce dimensions rather than just markup size, pair this with the resize SVG tool to set a smaller intrinsic width and height.
Frequently asked questions
How do I optimize an SVG online?
Paste your SVG markup into the tool on this page and click Optimize. The tool strips comments, unnecessary whitespace, and other safe structural cruft like metadata blocks and editor-specific attributes, then shows the before and after file size so you can copy or download the result.
Is this SVG optimizer free?
Yes. This SVG optimizer is free to use, with no account required.
Does my SVG file get uploaded to a server?
No. The optimization runs entirely in your browser: the file itself is not sent to a server.
Will this change how my SVG looks?
No. This is a conservative, lossless optimizer. It only removes things that have no effect on rendering, such as XML comments, empty attributes, whitespace between tags, metadata blocks, and editor-specific attributes and empty groups left behind by tools like Inkscape. It never touches path data or changes the artwork's geometry.
How much smaller will my SVG get?
It depends on the file. SVGs exported from design tools with lots of comments, metadata, and editor-specific markup often shrink noticeably; a file that's already compact, such as one exported from a tool that doesn't add that cruft, may only shrink a little.
Can I get more aggressive optimization, like shorter path data?
Not from this tool: it intentionally sticks to safe, lossless transforms. For more aggressive optimization, such as re-encoding path data or merging attributes, use the full SVG Lab editor.