Stripping editor metadata, empty groups, and unused SVG attributes
Vector graphics exported from desktop and browser design tools routinely carry 30% to 60% non-rendering XML overhead. Stripping non-visual namespaces, redundant wrapper elements, and default presentation attributes shrinks inline component bundles and standalone .svg icons while keeping every Bézier curve, stroke cap, and coordinate visually identical inside your tab.
Cleaning Figma, Illustrator, and Inkscape export namespaces
Design editors embed private round-trip state so projects reopen with layer names and artboard guides intact. Leaving Strip XML header & comments and Strip editor metadata (Figma, Inkscape, Illustrator) checked removes <?xml ...?> preambles, <!DOCTYPE> declarations, HTML comments, RDF <metadata> blocks, <sodipodi:namedview> tags, and inkscape:*, sodipodi:*, sketch:*, and serif:* attributes.
That same pass clears data-name layer labels, xml:space="preserve", legacy version="1.1" flags, deprecated enable-background directives, and unused xmlns:xlink declarations when no xlink:* attribute remains. If you want to audit raw node nesting before minification, open the file in the XML formatter to inspect deeply indented vendor blocks first.
Collapsing wrapper groups and sanitizing untrusted SVG scripts
Illustration exports frequently wrap single paths inside three or four nested <g> containers left behind after ungrouping artboards. Under the W3C SVG 2 Document Structure Specification, <g> elements without presentation attributes, transforms, or IDs contribute zero visual styling, so Collapse empty groups (<g>) iteratively unwraps attribute-free wrappers and deletes empty <g/> and <defs/> nodes.
Because third-party vector downloads can hide active payloads, every run also strips <script> blocks, inline on* event handlers, javascript: URIs, and external CSS @import or remote url() beacons. Spaces inside <text> elements are isolated before inter-tag whitespace collapses, ensuring typographic labels never lose deliberate word spacing.
Why do aggressive SVG minifiers break gradients, masks, or path curves?
Aggressive SVG minifiers corrupt artwork when naive regular expressions round path coordinates blindly or strip id attributes that internal paint servers still reference. Preserving visual fidelity requires parsing SVG path commands by parameter count and scanning every CSS, ARIA, and URL reference before deleting a single element identifier.
Command-aware path decimal rounding across 1 to 4 places
Desktop editors often serialize cubic curves with 4 to 8 decimal places such as M 38.5000,61.2500. Adjusting Coordinate decimals between 1 and 4 (default 2) rounds path coordinates, points, viewBox, transform matrices, and geometric attributes (x, y, cx, cy, r, rx, ry, width, height, stroke-width) while stripping trailing zeros like .000.
Naive regex rounders often fuse adjacent decimals or corrupt compact elliptical arc flags permitted by the W3C SVG 2 Path Data Grammar Specification, where 7-parameter A commands pack single-bit 0 and 1 flags without spaces (a4 4 0 014-4). Our parser steps through M, L, H, V, C, S, Q, T, A, and Z arity token by token so arc flags and negative offsets stay valid.
Reference-safe ID pruning for gradients, masks, and sprite sheets
Blindly deleting id attributes breaks <linearGradient>, <radialGradient>, <clipPath>, <mask>, and <filter> definitions that shapes reference via fill="url(#id)". When Remove unreferenced IDs is active, the optimizer first indexes every #id target inside url(), href, xlink:href, aria-labelledby, aria-describedby, and embedded <style> selectors, removing only orphaned layer names like id="Layer_1".
External icon sprite workflows also rely on <use href="sprite.svg#icon-name"> references from outside the file itself, so the cleaner preserves every id placed on <symbol> and <view> elements automatically. Architecture diagrams behave the same way when you turn Mermaid diagram syntax into standalone SVG files and minify the exported flowchart markup for documentation sites.
Responsive viewBox scaling vs fixed width and height attributes
Hardcoded width="120px" and height="120px" attributes lock an SVG to a fixed pixel box and prevent fluid CSS sizing inside modern grid or button layouts. Under the W3C SVG 2 Coordinate Systems and viewBox Specification, the four-number viewBox (min-x min-y width height) establishes an internal user coordinate grid so parent CSS selectors control rendered dimensions cleanly.
Enabling Responsive viewBox (drop fixed width/height) checks whether a valid viewBox already exists; if an older export only specifies physical or pixel dimensions (px, pt, pc, in, cm, mm at 96 px per inch), it synthesizes viewBox first before removing root width and height. When downstream slides or email clients reject vector markup, you can rasterize vector SVG graphics into PNG, JPG, or WebP after cleanup.
| Control in Optimization options | Default | Transformation applied | When to adjust |
|---|---|---|---|
Coordinate decimals (1–4) |
2 |
Rounds path d, points, transform, viewBox, and shape coordinates |
Set 3 or 4 on tiny 12 px grids or dense maps |
| Strip XML header & comments | Checked | Removes UTF-8 BOM, <?xml ...?>, <!DOCTYPE>, and comments |
Uncheck for legacy parsers needing XML preambles |
| Strip editor metadata | Checked | Deletes <metadata>, <sodipodi:namedview>, editor namespaces, and data-name |
Uncheck to retain embedded RDF license blocks |
| Remove unreferenced IDs | Checked | Strips unused ids while keeping url(#id), ARIA, <style>, and <symbol> IDs |
Uncheck if scripts query specific <path id> nodes |
| Shorten hex colors & defaults | Checked | Converts rgb() to hex, shortens #rrggbb to #rgb, drops opacity="1" |
Keep enabled on web and app vector assets |
Collapse empty groups (<g>) |
Checked | Deletes empty <g/> and <defs/> tags and unwraps bare <g> wrappers |
Uncheck if CSS targets svg > g > path selectors |
Responsive viewBox |
Unchecked | Synthesizes viewBox if missing, then drops root width and height |
Enable for fluid CSS components; skip for fixed <img> tags |
| Pretty-print indented markup | Unchecked | Formats 2-space indented XML instead of single-line output | Enable when reviewing diffs in Git pull requests |
Theming icons with currentColor and batch-saving optimized ZIPs
Design tools export monochrome icons with fixed hex codes such as stroke="#111111" or fill="#000000", blocking CSS hover states and dark-mode text inheritance in React, Svelte, Vue, or Astro components. Rewriting paint attributes alongside shortening hex colors turns static exports into theme-adaptive icons ready for single-file copy or batch archive download.
Converting hardcoded fills and strokes without filling hollow paths
Checking Shorten hex colors & defaults converts verbose rgb(255, 255, 255) declarations into lowercase hex, condenses matching six-digit pairs into three-digit #fff shorthand, and removes redundant opacity="1", fill-opacity="1", and stroke-opacity="1" attributes. Checking Convert fills/strokes to currentColor goes one step further using the keyword defined in the MDN CSS Color Value and currentColor Reference so icons inherit their parent button or link color property automatically.
To prevent turning stroked outline icons into solid silhouettes, the converter skips fill="none", transparent, and url(#...) gradient or pattern references. If you are building a multi-tone illustration rather than a monochrome icon and need exact palette values from a screenshot, sample hex codes first in the browser-based image color picker.
Previewing backdrops and packaging multi-icon ZIP archives locally
Side-by-side Original and Optimized cards render sanitized Blob URL previews up to 360 px wide with a live byte-delta badge (before → after and percentage saved). Toggling currentColor automatically switches the preview bar from the 16 px Grid checkerboard to Light (#ffffff), and you can test contrast against Dark (#18181a) before clicking Copy SVG or Save optimized SVG (<name>-min.svg).
Dropping two or more .svg files queues the entire set in local tab memory without uploading proprietary logos or unreleased UI kits. Clicking Save optimized SVGs (.zip) runs your chosen settings across every file, deduplicates filenames with -min.svg suffixes, and bundles optimized-svgs.zip inside a dedicated Web Worker.
Tip: Enable Pretty-print indented markup when reviewing cleaned SVG changes in a pull request, then uncheck it before copying single-line production markup into an icon component library.