SVG Optimizer
Minify SVG files in your browser. Strips comments, useless whitespace, default attributes, and rounds long decimals. Files never leave your device.
🔒 Files never leave your browser — no upload, no server, no tracking.
Enter input above to see the result.
What is this for?
SVG Optimizer minifies SVG files by removing unnecessary bytes: comments, excess whitespace, redundant attributes, and overly precise decimals. It runs entirely in your browser with no server upload, making it safe for proprietary or sensitive files. The tool applies only conservative, safe optimisation passes — suitable for icons, logos, and web graphics where visual fidelity is already locked in.
When to use it
- Cleaning up SVG exports from design tools (Figma, Illustrator, Sketch, Affinity) before committing to version control. Removes tool-specific metadata and formatting cruft.
- Trimming inline SVG payloads embedded in HTML or CSS, where file size compounds across page views.
- Stripping verbose XML comments and generator declarations that design tools embed ("Created with Adobe Illustrator…").
- Pre-processing an SVG before encoding it as a
data:URL for use in stylesheets or HTML attributes. - Quick byte-reduction pass on icon sprite sheets or SVG symbol libraries used across multiple pages.
- Normalising SVG formatting before automated processing (e.g. stripping comments that might confuse regex-based transforms).
How it works
- Comment removal. Deletes all XML and HTML comments from the SVG source.
- Whitespace collapse. Removes unnecessary line breaks, indentation, and spaces between tags (but preserves intentional spacing in text content).
- Default attribute stripping. Removes common attributes that already match SVG defaults:
stroke="none",fill-rule="nonzero",clip-rule="nonzero",stroke-linecap="butt",stroke-linejoin="miter", andstroke-miterlimit="4". - Coordinate rounding. Rounds path data and coordinate values to 2 decimal places, reducing precision without visible impact on most graphics.
- Each pass is independent and can be toggled on or off via checkbox; you can see before/after file sizes immediately.
Common gotchas
- Not a replacement for SVGO. The production SVGO library performs path optimisation, shape merging, viewBox analysis, and dozens of other aggressive passes. This tool intentionally stays minimal — only safe, format-preserving optimisations — to run dependency-free in the browser.
- Default-attribute removal is conservative. Only a small whitelist of well-known defaults is stripped. If your SVG uses CSS rules that target these attributes explicitly (e.g.
[fill="none"] { … }), disabling "Strip defaults" prevents silent breakage. - Coordinate rounding loses precision. Two decimal places is safe for icons, logos, and UI graphics; for technical diagrams, cartography, or data visualisation requiring sub-pixel accuracy, disable rounding or round to more places manually.
- Whitespace collapse can break text. SVG
<text>and<tspan>elements that rely on multiple consecutive spaces will collapse them to one. Icon-only SVGs are unaffected; disable this pass if your SVG contains intentional multi-space text. - Visual regression possible with certain transforms. If your SVG relies on specific whitespace or attribute ordering (e.g. for XPath selectors in scripted SVG manipulation), review the output before deploying.
Privacy and performance
- All processing happens in your browser. No data is sent to any server; files stay on your device.
- The tool is fast enough for files up to several hundred kilobytes.
- Typical savings are 30–50% for design-tool exports; gains are smaller for already-minified SVG.