SVG Optimizer (SVGO) with Before/After Preview

Paste or drop an SVG exported from Inkscape, Illustrator or Figma and get a smaller file: SVGO removes editor data, shortens paths and numbers, and the preview shows both versions side by side.

Loading tool…

About the SVG Optimizer

Vector editors save far more than the drawing: XML declarations and doctypes, <metadata> blocks, sodipodi: and inkscape: attributes, unused gradients, hidden layers, default values and coordinates with eight decimals. This tool runs SVGO 4 with its preset-default plugin set, which removes that data, collapses groups, rewrites path data in its shortest form and rounds numbers to the float precision you choose. Editor exports usually shrink by 50–80%.

The options map to SVGO plugins. The viewBox is kept by default because without it the image cannot scale with CSS; “Remove width/height” (removeDimensions) does the opposite and makes the SVG fill its container. <title> is kept by default since it is the accessible name of the image. “Clean up IDs” shortens and removes unused IDs, which breaks CSS or JavaScript that refers to them, and “Prefix IDs” avoids collisions when several SVGs are inlined in one page. “Styles to attributes” (convertStyleToAttrs, not part of the preset) rewrites style="fill:red" as fill="red" so that default values can be dropped. “Replace colors with currentColor” makes an icon take the text color of its parent.

Optimisation is lossy in small ways: a precision of 1 or 0 visibly distorts small icons, and merging paths can change how overlapping shapes are drawn. That is why both versions are rendered next to each other — as <img> elements, where the browser never executes scripts or loads external resources of the SVG. The gzip figures show what is actually transferred when the server compresses responses, which is the fair number to compare.

How to use it

  1. Paste the SVG markup, open a file or drop an .svg on the input.
  2. Set the float precision — 3 is safe for most artwork, 2 or 1 suits simple icons.
  3. Tick the plugins you need: remove dimensions, prefix IDs, currentColor, xmlns for inline use.
  4. Compare the original and optimized previews and the sizes.
  5. Copy the result or download it as optimized.svg.

Frequently asked questions

Why should I keep the viewBox?
The viewBox defines the coordinate system. Without it the SVG cannot be resized with CSS: it is cropped instead of scaled. SVGO 4 no longer removes it by default, and neither does this tool.
The optimized SVG looks different. What should I change?
Raise the float precision first, then turn off “Merge paths”, “Styles to attributes” and “Convert shapes to paths”. If the SVG is styled or scripted from outside, also turn off “Clean up IDs”.
Is my SVG uploaded to a server?
No. SVGO runs as JavaScript in your browser, and the file never leaves your device.
When can I remove the xmlns attribute?
Only when the SVG is pasted inline into an HTML document, where the parser already knows the namespace. A standalone .svg file, or one used in <img> or CSS, does not render without it.

Related tools