How to optimise an SVG
- Paste or open your SVG. Paste the code into the left box, press Open file, or drop an .svg file on the tool. The example already there is a sun icon exported from a drawing app.
- Check the result. The optimised code appears on the right as you type, with its new size and the percentage saved. The two previews below should look the same.
- Copy or download. The download is named like
logo.min.svg, so your original isn’t overwritten.
What gets removed
Drawing apps such as Illustrator, Inkscape, Figma and Sketch save a lot that browsers don’t need. svgo’s default preset removes or shortens:
- Comments, the XML declaration and the doctype.
- Editor data: namespaces like
inkscape:andsodipodi:, layer names and window settings. - Metadata blocks with licence and author details. If you need those, keep a copy of the original.
- Empty groups and definitions, hidden elements and default values written out in full.
- Long decimals, such as
32.000000written as32. - Styles moved from
style=""into shorter attributes, and colours shortened (#ffffffto#fff).
The options
| Option | What it does | Turn it off if |
|---|---|---|
| Decimal places | Rounds numbers in coordinates and paths. 3 is svgo’s default. | Small icons look slightly off (use 4 or 5) |
| Merge paths | Joins paths that share the same style into one | You animate or style paths separately |
| Shapes to paths | Writes rectangles, lines and polygons as shorter paths | Your CSS or code targets rect or circle |
| Shorten and remove ids | Removes ids nothing uses, shortens the rest | CSS, JavaScript or another file refers to the ids |
| Remove scripts | Strips scripts, event handlers and javascript: links | You wrote the SVG and need its script |
| Remove title | Drops the title screen readers announce | Leave it off unless the image is decorative |
| Remove width and height | Lets the SVG scale to fill its container | You need it to show at a fixed size |
| Indent the result | Makes the output readable, a little larger | You want the smallest file |
A worked example
The sample sun icon is a typical drawing-app export, about 1.7 KB. Optimised with the defaults, it drops to about 400 bytes, roughly 77% smaller, and looks identical. The eight separate lines become one path, and the title is kept. Most of that saving is editor data and long decimals. A hand-written or already-optimised SVG will save much less, which is a sign it was already tidy.
Served over the web with gzip or Brotli compression, the gap narrows, but smaller SVGs still mean less to download and parse, and the code is far easier to read when you paste it into HTML.
Common mistakes
- Removing the viewBox. It’s what lets an SVG scale. This tool always keeps it.
- Rounding too hard. 0 decimal places is fine for big illustrations but can make small icons wobble. Check the preview.
- Breaking references. If your page’s CSS styles
#logo-dotinside the SVG, untick “Shorten and remove ids”. - Optimising the only copy. Keep the editable original. Optimised SVGs are harder to edit in drawing apps.
Making a site icon from your SVG? The favicon generator turns it into favicon.ico and app icons. To get a PNG or JPG of it, use the image converter.