Readers24
Tools

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.

Image ToolsRuns Locally in Browser 100% Free • No Sign-Up
Decimal Precision:
Raw SVG Input
Optimized SVG Output

How to Use SVG Optimizer

1

Upload an .svg file, paste XML, or load Sample SVG

Load raw vector code exported from Figma, Illustrator, or Inkscape into the left editor.

2

Adjust optimization toggles & Decimal Precision

Toggle metadata/comment stripping, empty <g> cleanup, and coordinate rounding (1, 2, or 3 decimals, or keep original).

3

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.

Sample Input
<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>
Actual Output
<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.

Sample Input
<div>Not an SVG</div>
Actual Output
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.
Privacy & Execution ArchitectureAll parsing, conversion, formatting, and generation for this tool executes locally inside your web browser with zero server storage.
Read Privacy Policy

Related Workflow Tools

Complementary utilities commonly paired with SVG Optimizer

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.