SVG Optimizer
Compress SVG files with SVGO 4 in your browser. Before/after size, gzip size and preview, plus batch optimize up to 200 files to a .zip.
Lower is smaller. 1–2 suits 24px icons; keep 3 or more for large, detailed art.
Optimize many files at once
Up to 200 SVGs with the settings above, downloaded as one .zip.
How to Optimize an SVG
- Add an SVG. Paste the code, drop an .svg file on the box or upload one. For a folder of icons, use "Choose SVG files" to optimize up to 200 at once.
- Tune the settings. Lower the number precision for small icons, and turn on options such as currentColor or Remove width/height when you need them.
- Compare. Check the before and after preview, the byte saving and the gzipped size.
- Download. Copy the code, download the .svg, copy it as a CSS data URI, or download the whole batch as a .zip.
What the Optimizer Removes
| What | Example | Effect |
|---|---|---|
| Editor metadata | Sketch, Illustrator and Inkscape attributes, <metadata>, comments | Often 20–50% of an exported icon. |
| Over-precise numbers | 10.500000 → 10.5, path data rewritten with relative commands | The biggest win on paths. |
| Default values | fill-rule="nonzero", stroke="none" on shapes that inherit it | Safe: the browser assumes them anyway. |
| Useless groups | <g> wrappers with no attributes, empty <defs> | Flatter, smaller markup. |
| Shapes as paths | <rect>, <line>, <polygon> → <path> when shorter | Fewer bytes, same pixels. |
| Scripts | <script> elements and on* event attributes | Removed here on purpose, for safety. |
Use the Same Settings in Your Build
To optimize on every build instead, install SVGO and save the settings as a config file:
// npm i -D svgo then: npx svgo -f ./icons
// svgo.config.mjs
export default {
multipass: true,
floatPrecision: 2,
plugins: [
'preset-default',
'removeScripts',
// 'removeDimensions', 'prefixIds', ...
],
};Next step for icons: turn the optimized file into a component with the SVG to JSX converter, or make PNGs and a favicon with SVG to PNG. To inline an image as Base64 instead, try Image to Base64.
Need an icon to start from? Browse Material Symbols, Lucide, Heroicons, the free CC0 icon packs or this week's new icons.
Frequently Asked Questions
- Which version of SVGO does this use?
- SVGO 4, the same engine as the svgo npm package and SVGOMG, running entirely in your browser. The settings map to the preset-default plugins plus the toggles shown, so you can copy them into an svgo.config.mjs file.
- Will optimizing change how my SVG looks?
- At the default precision it should look identical. Very low precision (0 or 1) can shift curves on large artwork, so compare the before and after previews. Keep 3 or more decimals for detailed illustrations and maps.
- Does it keep the viewBox?
- Yes. SVGO 4 no longer removes the viewBox or the title by default, so the SVG still scales and stays accessible. Turn on Remove width/height to make it scale purely with CSS.
- What is the gzipped size?
- Servers usually send SVG compressed with gzip or Brotli, so the gzipped size is closer to what users download. The tool measures it with your browser’s CompressionStream API.
- When should I use Prefix IDs?
- When you inline several SVGs in one HTML page. Two icons that both define id="a" for a gradient or clip path will clash; prefixing makes every ID unique.
- Is it safe to optimize SVGs from unknown sources?
- The tool always removes script elements, and the previews show the SVG as an image, where scripts cannot run. Still, check SVGs from untrusted sources before you inline them in a page.
Sources & Standards
Last reviewed .
Related Tools
SVG to JSX ConverterTurn any SVG into a React (JSX/TSX), Angular, Vue or Svelte component with a size prop and currentColor. SVGO cleanup built in; nothing is uploaded.SVG to PNG, ICO & FaviconExport an SVG as a sharp PNG, WebP or JPG at any size, a multi-size .ico, or a complete favicon set with Apple touch icon, maskable icons and manifest.mat-icon SVG Migration HelperMove Angular Material mat-icon from the icon font to SVG: rewrites templates to svgIcon, downloads only the Material Symbols you use, and writes the MatIconRegistry code.Image to Base64Convert PNG, JPG, SVG, WebP and other images to Base64 or a data URI, ready to paste as an img tag, CSS or Markdown. Nothing is uploaded.