Developer Tools

SVG optimizer.

Shrink an SVG with SVGO, the standard open-source optimizer. Choose what to strip, see the exact bytes saved, and compare the original and optimized drawings side by side. Your file never leaves the browser.

How it works

The page loads the SVGO 4.1.0 browser build (MIT licence), served from this site so your file never touches a third party, and calls optimize() on your markup with the preset-default plugin set. Your toggles map to SVGO settings: the metadata switch disables removeDoctype, removeXMLProcInst, removeComments, removeMetadata and removeEditorsNSData when off; precision is SVGO's floatPrecision (default 3); keeping the viewBox simply leaves out the removeViewBox plugin, which is not part of the default preset; the title switch adds removeTitle.

Savings are (original bytes − optimized bytes) ÷ original bytes, with bytes counted as UTF-8. The visual diff draws both versions to canvases at the same size and counts pixels whose RGBA values differ by more than 8 per channel (out of 255).

Worked example: an Inkscape-style 48×48 icon (circle plus check mark, with a sodipodi:namedview, RDF metadata, a creator comment and six-decimal coordinates) is 962 bytes. With default options SVGO 4.1.0 outputs 302 bytes, a 68.6% saving. At precision 1 it is 286 bytes (70.3%); at precision 0 it is 276 bytes (71.3%), but the circle radius 20.5 rounds to 21, a visible change, which is why precision 0 is a trade-off rather than a free win. Use Load sample to reproduce these numbers.

Sources, read 2026-09-30: SVGO on GitHub (MIT), preset-default plugin list, convertPathData / floatPrecision, svgo on npm (version 4.1.0). Savings depend on the file; the figures above are for that example only.

How to optimize an SVG

Open an .svg file (it is read in your browser, not uploaded) or paste the markup, leave the options at their defaults, and press Optimize. The result shows the original and optimized size in bytes, the percentage saved, the optimized markup to copy or download, and a side-by-side preview with a count of pixels that differ. Change one option at a time so you can see what each one costs.

A second worked example: an editor-exported home icon

This 24×24 icon is 431 bytes as exported, with an XML prolog, an editor comment, a metadata block, a group carrying the stroke settings and six-decimal numbers:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generator: Editor 1.0 -->
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" version="1.1">
  <title>Home</title>
  <metadata>exported</metadata>
  <g id="layer1" fill="none" stroke="#000000" stroke-width="2.000000">
    <path d="M 3.000000 10.500000 L 12.000000 3.000000 L 21.000000 10.500000 L 21.000000 20.000000 L 3.000000 20.000000 Z"/>
  </g>
</svg>

With the SVGO 4.1.0 default preset and multipass, the output is 187 bytes, a 56.6% saving:

<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><title>Home</title><path fill="none" stroke="#000" stroke-width="2" d="M3 10.5 12 3l9 7.5V20H3Z"/></svg>

What happened: the prolog, comment and metadata were removed; #000000 became #000; 2.000000 became 2; the path data was rewritten with relative commands and no redundant zeros; the group and its id disappeared, and its attributes moved onto the path. The drawing is the same. Ticking Remove <title> gives 168 bytes (61.0%), at the cost of the icon’s accessible name. Setting precision to 0 gives 181 bytes (58.0%), but the path becomes m3 11 9-8 9 8v9H3Z: the 10.5 coordinates were rounded to 11, which moves the roof edges by half a unit on a 24-unit grid. That is why the preview and the pixel count are there.

What each default change does

Where the savings come from, and where they do not

Editor-exported files (from vector design tools) carry the most removable weight. A file that is already hand-tuned or has been through SVGO once may shrink by only a few percent, and a file made mostly of long path data shrinks mainly by rounding numbers. SVG is text, so web servers can also compress it with gzip or Brotli; optimizing first still helps, but the saving after compression is smaller than the saving in raw bytes shown here.

Command line and build use

This page runs the same library you can use in a project. SVGO has a command line (for example svgo one.svg -o one.min.svg) and an optimize() function for build scripts, with a svgo.config file to keep your plugin choices consistent across a repository. Use this page to decide the settings, then put them in the config.

Accessibility and safety

An inline SVG can be given an accessible name by a <title> child, so remove it only for decorative graphics. SVG files may contain scripts and external references; SVGO does not remove scripts by default, so treat unknown files as untrusted. The preview here draws through an image element, which does not run scripts in the file.

Sources

Each source below was opened and checked in October 2026 (retrieved 2026-10).

Frequently asked questions

Is my SVG uploaded anywhere?

No. The file is read with the browser's FileReader and optimized in a script on this page. The SVGO library is served from this site, and no request carries your file.

Why keep the viewBox?

Without a viewBox an SVG with fixed width and height cannot scale to its container. SVGO 4 keeps it by default; only turn this off if you know the file is always shown at its intrinsic size.

Will optimizing change how my graphic looks?

With default options it should not, and the pixel diff shows any difference. Lower precision, removing the title, or removing IDs that scripts or CSS reference can change appearance or behaviour, so check the diff before shipping.

Does it handle SVGs with scripts?

The preview renders through an image element, which never runs scripts inside the SVG. SVGO does not remove scripts by default; remove them yourself if the file comes from an untrusted source.

How much smaller will my SVG get?

It depends on the file. The editor-exported icon above shrinks 56.6% with default settings and the sample on this page shrinks 68.6%. A file already optimized by hand or by SVGO may shrink very little. The tool shows the exact bytes saved for your file.

Is it safe to remove the title from an SVG?

Only if the graphic is decorative. For an inline SVG, the title element provides the accessible name, so removing it leaves a screen-reader user without a label. If the SVG is used as a CSS background or decoration, the title is not needed.

What does precision do?

It sets how many decimal places SVGO keeps in numbers such as path coordinates. Lower values make files smaller but can shift shapes. Check the preview and pixel difference after lowering it; three decimals is the default here.

Why does the optimized SVG look different?

Usual causes are precision set too low, an ID that CSS or script referred to being changed, or a removed attribute that a stylesheet depended on. Compare the preview, turn options off one at a time, and keep the original file.

Can I optimize many SVGs at once?

Not on this page, which handles one file at a time. For a folder, run SVGO from the command line with the recursive option, or call optimize() in a build script, using the settings you chose here.

Does optimizing remove scripts from SVG files?

No. Scripts are not removed by the default preset. If a file comes from an untrusted source, remove scripts and external references before using it.

Processed entirely in your browser

Your SVG is optimized locally and is never sent to a server. Always review the result before replacing the original file.

Advertisement
Advertisement