SVG Optimizer
Published Updated
Shrink an SVG with SVGO using the Default, Aggressive or Clean Only preset, then compare the file sizes.
Measured on a test file
We built an original 3,782-byte SVG with typical editor boilerplate: namespaces, a comment, metadata, an unused gradient, 6-decimal numbers and rgb() colors, then ran each preset through the same SVGO configuration the tool uses.
| Preset | Result | Saved | xmlns kept | title kept |
|---|---|---|---|---|
| Clean Only | 2,560 bytes | 32% | Yes | Yes |
| Default | 1,443 bytes | 62% | Yes | Yes |
| Default plus remove viewBox | 1,421 bytes | 62% | Yes | Yes |
Real files will differ.
What each preset does
All three run SVGO with multiple passes.
- Default runs SVGO's preset-default: it removes comments, metadata and editor data, merges and minifies styles, shortens IDs, rounds numbers and rewrites path data.
- Aggressive is Default with number and path precision cut to 2 decimals, plus
removeTitle. - Clean Only removes comments, metadata, editor-specific namespaces, elements and attributes, and descriptions written by the editor, and leaves the path code alone.
Optimizing an SVG
Step 1
Add an SVG
Pick a .svg file. The preview and the current size appear.
Step 2
Pick a preset
Default, Aggressive or Clean Only. Two checkboxes decide whether the viewBox is removed and whether colors are shortened.
Step 3
Optimize, then download or copy
The result card shows the old and new size. Download the file or copy the markup to paste inline.
What Aggressive takes away
The title element is the accessible name and the hover tooltip of many icons, so deleting it can hurt screen reader users. The rounding to 2 decimals can change shapes with small coordinates, as the tests further down show, so Default or Clean Only suit files where that matters.
The viewBox checkbox forces removal even when SVGO would keep it. Colors in attributes are shortened by default, for example a fill of rgb(0,0,128) becomes navy, and the colors checkbox turns that off. In a test file with the colors inside a style attribute, Default and Aggressive shortened them even with the box unticked, and Clean Only left them as written.
Rendered before and after, three test files
We wrote three SVGs by hand, ran each through the tool's own SVGO setup (SVGO 4.1.0, the browser build, multipass, colors converted), drew the original and every result at 256 x 256 on a white canvas, and counted the pixels where any color channel differed by more than 8 levels out of 255. The first two files hold the same squiggly 40-segment curve at two coordinate scales. Chromium is 153.0.8010.12 (the Playwright build, headless) and WebKit is Playwright's build (user agent Version/26.6, not the Safari app).
| Test file (original size) | Preset | Size | Pixels that differ, Chromium | Pixels that differ, WebKit |
|---|---|---|---|---|
| Icon, viewBox 0 0 24 24, 3-decimal path (1,885 B) | Clean Only | 1,824 B | 0 | 0 |
| Default | 1,620 B | 0 (largest step 8) | 0 (largest step 1) | |
| Aggressive | 1,320 B | 938 (largest step 131) | 828 (largest step 51) | |
| Same curve, viewBox 0 0 1 1, 6 decimals (2,396 B) | Clean Only | 2,389 B | 0 | 0 |
| Default | 1,105 B | 7,695 (11.7%) | 7,005 (10.7%) | |
| Aggressive | 820 B | 15,617 (23.8%) | 15,510 (23.7%) | |
| Style rule by id, class, and two use elements (369 B) | Default | 321 B | 204 (largest step 11) | 0 |
| Aggressive | 321 B | 204 (largest step 11) | 0 |
The result for the 0-to-1 file is the one to read twice. Default is the preset selected when the tool opens, and on this file the picture changed visibly, probably because the numbers in the path are rounded. Clean Only left the same file unchanged in our test. In the third file Default folded the style rule into style attributes, kept the use elements and renamed the shared circle to a short id; the 204 differing pixels in Chromium, all within 11 levels, were not there in WebKit.
Smaller facts from the same run
- Ticking the option that removes the viewBox took the icon from 1,620 to 1,600 bytes and left the width and height attributes in place.
- Turning color shortening off kept the rgb() values and gave 1,627 bytes instead of 1,620.
- A file with only a viewBox and no width or height kept the viewBox under Default and under Aggressive, and Aggressive kept its xmlns attribute.
- Markup that is not well formed, such as an unclosed tag, makes SVGO throw an error, and the tool shows its general message that the markup could not be optimized. Text that is not SVG at all fails the same way.
SVG Optimizer FAQ
How much smaller will my SVG get?
It depends on how much editor clutter it carries. On a test file we built in the style of an Inkscape export (3,782 bytes), Clean Only gave 2,560 bytes, Default 1,443 and Aggressive 1,337. Files that are mostly path data shrink less, and a file with an embedded bitmap barely shrinks.
Does an Aggressive result still open as an image?
Yes for the three files we drew. A browser needs the xmlns attribute to treat a standalone file as SVG, and in our check neither Chromium 153 (Playwright build, not Google Chrome) nor WebKit 26.6 could draw a file without it. Aggressive keeps xmlns, and its three results showed as images in both browsers.
Does it change how the graphic looks?
Clean Only left the picture alone in our test. Default and Aggressive round the numbers in the paths, and on a drawing whose coordinates only run from 0 to 1 that changed the picture visibly: about 12 percent of the pixels of a 256 x 256 render in Chromium 153 differed by more than 8 levels after Default and about 24 percent after Aggressive. On a 24-unit icon Default changed no pixel by more than 8 levels in Chromium 153. Compare the preview in the result before you replace your original.
Should I tick the option that removes the viewBox?
Usually not. The viewBox is what lets the graphic scale to the space it is placed in. Removing it is for files that already have fixed width and height and where you want those to apply.
Does it shrink bitmaps inside the SVG?
No. SVGO works on the markup. A Base64 PNG or JPEG inside the file is left as it is.
Which version of SVGO runs here?
SVGO 4, loaded from the package's browser build when you press Optimize. Its plugin list is in the SVGO preset-default documentation.
Is Default safe for a drawing with tiny coordinates?
Not in our test. A curve in a viewBox of 0 0 1 1 came out 54 percent smaller under Default, and about 11 to 12 percent of its pixels changed by more than 8 levels in a 256 x 256 render in Chromium 153 and WebKit 26.6. Clean Only left the same file unchanged.
Is Aggressive safe to use for a file that stays a file?
It rounds numbers to 2 decimals, which changed a small-coordinate drawing a lot in our test, and it removes the title element. The result keeps xmlns, so it still opens as an image.