SVG · 14 tools · nothing uploads

Optimize SVG

Shrink SVG files with svgo: same rendering, fewer bytes. Drop as many as you like.

Input

Options

Optimize SVG runs svgo's default preset, repeating passes until the file stops shrinking, and returns it as -min.svg with the byte count either side. Turning multipass off leaves a single pass. Disable lists plugin names to turn off, such as cleanupIds when an outside script addresses one. A non-svg root is refused before svgo can gut it.

Questions

Does it change how my SVG looks?

It is not supposed to. The engine is svgo with its default plugin preset, which removes comments, editor metadata, unused definitions and redundant attributes, and rewrites path data and numbers more compactly. The viewBox is kept, because the plugin that would remove it is not part of the default preset, so a responsive SVG stays responsive.

Will it break my CSS or JavaScript that targets ids?

It can, if the ids are referenced from outside the file. svgo removes unused ids and shortens the ones it can see being used, so an id that only your stylesheet or script knows about might be renamed or dropped. svgo skips that cleanup entirely when the SVG itself contains a style or script element. Check any icon you address by id from a sprite sheet.

What is multipass and should I leave it on?

Multipass repeats the optimization until the output stops getting smaller, and it is on by default. Turning it off means a single pass, which is faster and slightly more conservative. On a normal icon or illustration the difference is a few percent.

Why does it refuse my file with "not an SVG"?

Because the root element is not an svg element, or the file contains no XML element at all, and the error says which. svgo would still appear to succeed on such a file and hand back a destroyed document announced as a large saving, so the file is checked before svgo touches it. If you have an SVG fragment, wrap it in an svg element with the SVG namespace first; if the SVG is embedded in a bigger document, extract it into its own file.

What does "refusing to report a saving" mean?

It means optimizing emptied your file out. A document rooted at svg whose contents are not SVG passes the first check, and svgo then drops every child it does not recognise, leaving something that would draw nothing. The tool compares before and after, and if the result draws nothing while the input drew something, it refuses and leaves your file untouched.

What is the output called, and can I do a folder at once?

Each file comes back as its own result named with -min before the extension, so logo.svg becomes logo-min.svg, along with a line giving the byte count before and after and the percentage change. Drop as many files as you like; each is optimized separately, and everything runs in this browser tab.

How do I keep one specific optimization from running?

List the plugin names in disable, separated by commas, for example cleanupIds,mergePaths. Each named plugin is turned off inside svgo's default preset and everything else still runs. A name that is not part of the default preset, such as removeViewBox, is skipped rather than refused, so a typo costs you a smaller saving rather than a failed run. The page's own workspace shows the same toggles as checkboxes, with a before and after render and the optimized code beside them.

Compare

ToolRuns on the CLILive as you type
Optimize SVGYesNo
SVG to PNGYesNo
SVG to PDFYesNo
Trace a raster image to SVGYesNo

Related SVG tools