SVG Optimizer
Guide: SVG vs PNG: When to Use Each and How to Shrink SVG Files
Drag an SVG file here, or
Your images stay on your device. Nothing is uploaded.
813 B → 234 B (71% smaller)
Check that the two pictures look the same before you use the result. If something changed, turn off the options one at a time, starting with rounding.
Nothing you enter or choose here leaves your device. This tool runs in your browser.
A real before and after
Here's a small SVG as an editor might export it, and what the optimizer makes of it:
<?xml version="1.0" encoding="UTF-8"?> <!-- Generator: Illustrator --> <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"> <metadata>editor data</metadata> <rect x="10.000000" y="10.000000" width="80.123456" height="80.123456" fill="#ff0000"/> <circle cx="50.000000" cy="50.000000" r="20.500000" fill="#ffffff"/> </svg>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect x="10" y="10" width="80.123" height="80.123" fill="#f00"/><circle cx="50" cy="50" r="20.5" fill="#fff"/></svg>
The file went from 362 bytes to 203, a saving of 44 percent. The XML header, the comment and the metadata are gone, numbers have been rounded and trailing zeros dropped, and the colors have been written in their short forms. The picture looks identical.
Where the savings come from
| What's removed or shortened | Typical effect |
|---|---|
| Editor metadata, comments and the XML header | A few hundred bytes to several KB |
| Long decimals such as 80.123456 | Often the biggest saving in complex paths |
| Extra spaces and line breaks | A small percentage |
| Long color codes like #ffffff | A few bytes each |
| Unused ids and empty groups | Depends on the file |
Files exported from Inkscape, Illustrator or Sketch often shrink by half or more. Clean, hand-written SVGs shrink less.
Check before you replace
The page shows the before and after pictures side by side. Look at them closely, especially at large sizes. The one setting that can visibly change a shape is rounding numbers to too few places. Keep at least 2 or 3 decimal places for detailed artwork, and fewer is fine for simple icons.
Accessibility and ids
- Title and description are read out by screen readers. Leave them in unless the picture is purely decorative. Removing them is off by default.
- Ids are kept when something refers to them, such as a gradient or a use element. If the file has a style or script block, all ids stay, since the tool can't be sure what they're used by.
- Don't strip viewBox. Without it the picture can't scale properly.
Putting SVGs on a page
Small icons can go straight into the HTML, which saves a request and lets CSS color them. Larger drawings are better as separate files that the browser can cache. Either way, a smaller file loads sooner.
Files stay in your browser. To get a PNG from the result, use SVG to PNG, and the guide to SVG and PNG explains when to choose each format.
A routine for a set of icons
- Export all the icons from your design tool with the same settings.
- Optimize each one with the defaults and compare before and after at a large size.
- Keep the decimals at 2 or 3 places for anything with curves.
- Save the results under clear names, and keep the originals in a source folder in case you need to edit them later.
Written by Akinrinmade Michael · Updated October 24, 2026
How to use
- 1Drag in an SVG file, or paste the SVG code.
- 2Keep the default options, or switch some off.
- 3Compare the before and after pictures, then copy or download the result.
Frequently asked questions
Is my SVG uploaded?
No. Everything happens in your browser, so your files are never uploaded.
How much smaller will it get?
Files exported from Inkscape, Illustrator or Sketch often shrink by half or more, because they carry editor data, metadata and long numbers. Clean hand-written SVGs shrink less.
Will it change how my picture looks?
The defaults are meant to keep it identical, and the page shows the before and after side by side so you can check. Rounding numbers to too few places is the one option that can change the shape, so keep at least 2 or 3.
Is it safe to remove the title and description?
They are used by screen readers, so only remove them for purely decorative pictures. That option is off by default.
Why are some ids kept?
An id is kept if something refers to it, such as a gradient or a use element. If the file has a style or script, every id is kept to be safe.
Read the guide
Learn how this works and how to get the most from it.
Images
SVG vs PNG: When to Use Each and How to Shrink SVG Files
How vector SVG differs from PNG, when each is best, how to turn an SVG into a PNG at any size, and how to clean up and optimize SVG files.
3 min read
Related tools
SVG to PNG Converter
Turn SVG files into PNG, JPG or WebP at any size.
Image Compressor
Make JPG, PNG and WebP images smaller. Private, in your browser.
CSS Minifier & Beautifier
Compress CSS to save bytes, or format it so it is easy to read.
Image to Base64 Converter
Convert an image to a Base64 data URI, or turn Base64 back into an image.