# SVG Optimizer

> Shrink SVG files: strip editor metadata, comments and default values, round path data and collapse whitespace, with a before and after preview.

- URL: https://www.tooljig.com/svg-optimizer
- Category: [Developer tools](https://www.tooljig.com/category/developer.md)
- Runs: In the browser; nothing uploaded
- Price: free, no account needed

## What it does

Paste SVG markup or open an .svg file to remove what browsers do not need: the XML prolog and doctype, comments, <metadata>, Inkscape, Sodipodi, Sketch and Illustrator attributes and namespaces, empty groups and attributes, and default values such as fill-opacity="1". Path data is rewritten with rounded numbers and minimal separators, numeric attributes are rounded to the decimals you choose, and whitespace is collapsed. Text, <style> and <script> contents are left intact. You see the size before and after and a side-by-side preview, all computed in your browser.

## How to use it

1. Paste SVG markup or choose an .svg file.
2. Adjust the decimals and the options.
3. Compare the previews, then copy or download the optimized SVG.

## Good to know

- This is a lighter optimizer than SVGO: it does not merge paths, convert shapes to paths, shorten IDs, minify CSS or convert absolute to relative coordinates, so SVGO can usually save more.
- Rounding relative path commands can add up small errors over long paths; if the preview shifts, use more decimals. Inherited defaults are only removed when no ancestor or <style> could override them.
- Comments starting with <!--! are kept as licence comments. Files up to 5 MB are accepted, and the markup must be well-formed XML.

## FAQ

### Will the optimized SVG look the same?

It should. The previews show both versions so you can check. If something differs, raise the number of decimals or turn off the option that caused it and compare again.

### Why keep the viewBox but remove width and height?

Without width and height the SVG scales to its container, which suits responsive layouts and icons sized with CSS. The viewBox keeps the aspect ratio. Leave the option off if the SVG must keep a fixed size.

### Is my SVG uploaded?

No. It is parsed and rewritten in your browser.

## Related tools

- [Image to Base64](https://www.tooljig.com/image-to-base64.md): Convert images to Base64, a data URL, an <img> tag or a CSS background-image, with the size increase shown. Several files at once; nothing is uploaded.
- [CSS Gradient Generator](https://www.tooljig.com/css-gradient-generator.md): Build linear, radial and conic CSS gradients with up to six color stops, preview them live and copy the background CSS with an optional fallback.
- [Image Converter](https://www.tooljig.com/image-converter.md): Convert images between PNG, JPG, WebP, GIF, BMP, TIFF and ICO.
