SVG Optimizer
Fine-tune SVG cleanup with safe toggles, decimal precision controls, and before/after stats.
How to optimize an SVG
Upload an .svg file or paste its markup, choose the cleanup steps, and click Optimize SVG. Uploading a file runs the optimizer immediately, and Load Sample shows the effect on a small icon. Compare the result with the original side by side, then copy it or download optimized.svg. Everything runs in your browser.
What each option does
- Remove comments: deletes
<!-- ... -->blocks, including generator notes added by design tools. - Remove metadata and descriptions: deletes
<metadata>and<desc>.<title>is always kept because it's the graphic's accessible name. Turn this off for inline SVGs that reference a description witharia-describedby. - Remove editor namespaces: deletes Inkscape, Sodipodi, and Affinity markup (elements such as
sodipodi:namedview, attributes such asinkscape:labelandserif:id, and their namespace declarations).xmlns:xlinkis removed only if noxlink:hrefremains, so the output stays valid XML. - Remove empty groups: deletes
<g>elements with nothing inside, repeating until none are left. Groups are removed even if they have anid, so turn this off if a script fills a placeholder group later. - Tighten attribute spacing: removes spaces around
=, sofill = "red"becomesfill="red". - Collapse whitespace: removes whitespace between tags and shrinks runs of spaces and line breaks to a single space, usually leaving one long line.
- Normalize decimals: rounds every decimal number to the precision you set (0–5) and drops trailing zeros. It's off by default because it's the only option that changes geometry.
The <?xml ... ?> declaration is always removed. It's optional for SVG files saved as UTF-8.
Choosing a decimal precision
Precision is measured in viewBox units, so the right setting depends on the coordinate system, not on the size the graphic is displayed at.
| Coordinate system | Try | Why |
|---|---|---|
| Icons with 16–48 unit viewBoxes | 2 | Error of 0.005 units or less, invisible at normal scales |
| Illustrations with viewBoxes hundreds of units wide | 1 | Error of 0.05 units or less, far below a pixel at typical sizes |
| Very large canvases (1000+ units) | 1, then 0 | Whole units are often enough, but check curves and thin strokes |
Normalized coordinates (0 0 1 1) | 3–5, or off | Each 0.01 step is 1% of the shape |
After optimizing, open the downloaded file next to the original at high zoom. If edges have moved, raise the precision by one and run it again.
Recommended settings by use case
- Icons used in
<img>tags or CSS backgrounds: turn everything on with precision 2. A title inside the file isn't used as alt text in this context, so put the description in thealtattribute instead. - Inline SVG in HTML or components: titles are always kept; turn "Remove metadata and descriptions" off if your markup points
aria-describedbyat a<desc>. Turn everything else on. - Sprites built from
<symbol>: safe to optimize. This tool never renames IDs, so<use href="#icon-name">references keep working. - Files you'll edit again: keep the original. Design tools rely on the metadata and namespaces this removes.
Reading the stats and the limits
The byte counts compare the original and optimized markup. The path and group counts describe the output. Paths are never merged, converted, or deleted, so the path count doesn't change, and the group count drops only when empty groups are removed. The tool also doesn't rewrite path commands, shorten colors, or remove hidden elements. Those changes save more bytes but can break animations, scripts, or CSS that target specific elements. If you'd rather pick a preset, the SVG Compressor runs the same cleanup with fixed settings.
Frequently Asked Questions
What's the difference between the SVG Optimizer and the SVG Compressor?
They use the same cleanup engine. The Optimizer lets you switch each step on or off and set decimal precision from 0 to 5. The Compressor offers three fixed presets, and every preset removes titles and descriptions.
Will optimizing break my SVG animations or CSS?
Usually not. The tool doesn't rename IDs or classes or reorder elements, so selectors and SMIL or CSS animations keep their targets. Two things to check: rounding also changes decimals inside <style> blocks and animation values, and empty-group removal deletes placeholder groups that scripts might fill later.
Does the optimizer keep the title element?
Yes. <title> is the accessible name of an inline SVG, such as an icon-only button graphic, so it's never removed. For decorative graphics or SVGs loaded through <img> (where alt provides the name), you can delete it by hand to save a few bytes.
What decimal precision should I use?
For most icons, 2 is safe. For large illustrations, 1 is usually enough. For normalized 0–1 coordinate systems, use 3 or more, or leave rounding off. Always compare the result at high zoom before you ship it.
Why does my optimized SVG show an XML error?
The optimizer keeps any namespace declaration that's still in use, so it shouldn't introduce XML errors. If you see one, check the original file first. Files that mix several custom namespaces can still trip up strict parsers; turn off "Remove editor namespaces", optimize again, and compare.
Is it safe to optimize confidential design files here?
Yes. The optimizer is plain JavaScript running in your browser. Your SVG isn't uploaded, logged, or stored.
Love using BreezyTools?
Go Pro for an ad-free experience, priority features, and support independent development — for less than a coffee a month.