SVG Optimizer
Clean and minify SVG vector code inside your browser: strip <script> elements, remove editor metadata and empty <g> layers, round coordinate decimals (1–3 places), and export optimized .svg files.
How to Use SVG Optimizer
Upload an .svg file, paste XML, or load Sample SVG
Load raw vector code exported from Figma, Illustrator, or Inkscape into the left editor.
Adjust optimization toggles & Decimal Precision
Toggle metadata/comment stripping, empty <g> cleanup, and coordinate rounding (1, 2, or 3 decimals, or keep original).
Inspect live vector preview, Copy SVG, or Download .svg
Verify rendered visual geometry safely inside the isolated <img> preview and inspect bytes saved.
Practical Use Cases
- Strip verbose <?xml?> headers, generator comments, Inkscape/Sodipodi attributes, and <metadata> from Illustrator or Figma SVG exports.
- Trim bloated 6-digit path decimal coordinates down to lean 2-decimal geometry for fast UI icon rendering.
- Remove nested empty <g> layer containers left behind after design cleanups.
- Produce clean minified SVG strings before converting logos into Base64 Data URLs or Favicons.
Real Input & Output Examples
Cleaning Vector Studio Sample Icon
Removes XML comments, metadata tag, empty group, and rounds 4-decimal coordinates to 2 decimals.
<svg viewBox="0 0 120 120"><metadata>Created with Vector Editor</metadata><g id="empty-layer"></g><rect x="10.0000" rx="24.500" width="100.0000"/></svg>
<svg viewBox="0 0 120 120"><rect x="10" rx="24.5" width="100"/></svg>
Invalid Non-SVG Input Validation
Pasting broken XML or plain HTML triggers an immediate parser error alert.
<div>Not an SVG</div>
Error: Invalid SVG markup. Make sure your input contains valid XML inside an <svg> root element.
Features, Supported Standards & Limitations
Automated <script> Removal & Isolated Preview
Strips all <script> nodes during DOM parsing and displays previews via an isolated Blob URL inside an <img> tag rather than inline DOM injection.
Targeted Editor Namespace & Metadata Cleanup
Removes <metadata>, <title>, <desc>, data-name, and inkscape:/sodipodi:/xmlns:dc/cc/rdf editor attributes.
Multi-Pass Empty <g> Pruning
Runs up to 4 bottom-up cleanup passes so nested empty group layers collapse completely.
Numeric Attribute Rounding
Rounds decimals cleanly across d, points, viewBox, x/y/x1/y1/x2/y2, width/height, cx/cy/r/rx/ry, and stroke-width.
Supported Formats, Standards & Inputs
- Valid XML SVG documents (<svg> root parsed via browser DOMParser 'image/svg+xml')
- Configurable precision: 1 decimal, 2 decimals, 3 decimals, or untouched originals
- Exports clean minified image/svg+xml (.svg) files
Limitations & Compatibility
- Uses clean DOM-level cleanup rather than full SVGO geometric path merging/curve conversion (so overlapping shapes stay intact without unpredictable path merging).
- Aggressive 1-decimal rounding on ultra-tiny micro icons (e.g., 16×16 viewBox) can distort fine strokes—choose 2 or 3 decimals for delicate geometry.
- Enabling metadata removal also strips <title> and <desc>; uncheck it if your inline SVG relies on an internal <title> for accessibility.
Related Workflow Tools
Complementary utilities commonly paired with SVG Optimizer
Favicon Generator
Create 16x16 to 180x180 web favicons and HTML links in a ZIP.
Image to Base64 Converter
Convert local images into Base64 Data URLs and HTML <img> snippets.
HTML Minifier
Remove HTML comments & excess spaces locally with byte savings.
CSS Minifier
Compress CSS rules locally with byte metrics & .min.css export.
Frequently Asked Questions
What decimal precision works best without distorting my icon?
2 decimal places is safe for virtually all 24px–512px icons. Choose 3 decimals (or Keep original) for complex detailed maps or very small viewBox grids.
Why does SVG Optimizer remove <script> elements?
Removing <script> blocks ensures untrusted third-party SVG assets stay safe static graphics before copying into your app or downloading.
Will removing <title> affect screen-reader accessibility for inline SVGs?
Yes, if you embed an SVG inline with an accessible <title>, uncheck 'Remove metadata, comments & editor tags' or add an aria-label directly onto your <svg> element.
Why does the optimizer fail on an SVG exported without a proper <svg> tag or broken XML?
Browser XML DOMParser requires well-formed XML tags inside an <svg> root element (with valid closing tags and escaped '&' attributes).
Should I optimize my vector logo here before using Favicon Generator?
Yes—cleaning editor bloat and previewing the icon here first ensures crisp scaling before Favicon Generator rasterizes your 16×16 to 180×180 PNGs.