SVG Optimizer

Shrink SVG files with SVGO and compare the result with the original.

About SVG Optimizer

An SVG optimizer that shrinks SVG files with SVGO in the browser, showing the size before and after and a rendered preview of both versions.

How to use

  1. Paste SVG markup or load an .svg file of up to 5 MB. The optimised markup appears as you type.
  2. Read the sizes under the editor: original, optimised and the percentage saved.
  3. Adjust the options if needed, and compare the two previews to check that nothing visible changed.
  4. Copy the result or download it as .min.svg, named after the loaded file.

What it does

  • Runs SVGO 4 with its default preset. That removes comments, metadata, editor data, the XML declaration and doctype, hidden and empty elements and unused definitions; collapses needless groups; converts basic shapes to paths; and shortens path data, colours, transforms, styles and ids.
  • Multipass runs the preset again until the output stops getting smaller.
  • Number precision sets how many decimal places are kept, from 0 to 8, with 3 as the default. Lower values save more and move points further from where they were.
  • Keep viewBox is on by default. Turned off, a viewBox that only repeats the width and height is removed. Remove width and height drops those two attributes and keeps a viewBox, so the image scales to its container.
  • Prettify indents the output by two spaces instead of writing one line.
  • The previews are drawn as images from data URLs, never inserted into the page as markup, so a script inside the SVG cannot run. An SVG without an xmlns attribute gets one for the preview only.
  • It does not convert SVG to PNG, outline text, embed fonts or offer a switch for each SVGO plugin. Ids are shortened, which can break CSS or scripts elsewhere that refer to them by name. Markup that is not well-formed XML is reported with a line and column, not repaired.

Example

<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24">
  <!-- red dot -->
  <g fill="none">
    <circle cx="12.000" cy="12.000" r="10.000" fill="#ff0000"/>
  </g>
</svg>
→ 202 B to 132 B, 34.7% saved
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="red"/></svg>

Privacy

Optimising and previewing run in the browser. The file is not uploaded, no request is made, and nothing is stored.

Frequently asked questions

How do I reduce the size of an SVG file?
Remove what the renderer does not need: comments, editor metadata, empty groups and default attribute values, then shorten path data and round coordinates to two or three decimal places. An optimiser such as SVGO does all of this in one pass.
Does optimising an SVG reduce its quality?
Usually not visibly. Most of the saving is data that never affected the drawing. The one lossy step is rounding numbers; at three decimal places the difference is far below a pixel for ordinary icons, but at zero or one it can shift curves, so compare the previews.
Should I remove the viewBox from an SVG?
No, in most cases. The viewBox is what lets an SVG scale to any size set in CSS. Without it the drawing stays at its original pixel size and is cropped when the element is smaller.
What is SVGO?
SVGO (SVG Optimizer) is an open-source tool, written for Node.js, that applies a set of plugins to an SVG to remove redundant data. It is what most build tools and image pipelines use to minify SVG. This page runs its browser build.