How to use
- Drop SVG files or click to choose them (up to 200). You can also paste SVG code copied from a design tool.
- Pick a mode (Safe, Maximum or Custom) and the number of decimal places. The result is calculated right away.
- Check each file’s original size, result size and savings in the table, then press Compare to see the original and the result side by side.
- Download files one by one or all together as a ZIP. You can also copy the code, a data URI or a CSS
background-imagerule.
What gets removed
SVG files exported from design tools carry a lot of baggage. The optimizer removes whatever does not change the picture.
| Target | Examples |
|---|---|
| Declarations and comments | <?xml ?>, <!DOCTYPE>, <!-- Generator: Adobe Illustrator --> |
| Editor data | <metadata>, Inkscape and Sketch attributes and namespaces |
| Needless structure | Empty <g>, groups wrapping a single child, elements that are never visible |
| Value notation | #ff0000 → red, 64.000 → 64, shorter path data |
| Styles | Minified CSS in <style>, rules moved onto elements |
Safe vs. Maximum
| Safe | Maximum | |
|---|---|---|
viewBox |
kept | kept |
width / height |
kept | removed (size comes from viewBox and CSS) |
id |
untouched | unused ids removed, the rest shortened |
| Passes | one | repeated until nothing shrinks further |
The example icon (Illustrator comment, metadata and .000 decimals, 588 bytes) at 3 decimal places comes out at 329 bytes in Safe mode (44% smaller) and 278 bytes in Maximum mode (52.7% smaller). Maximum also drops id="background" and the width/height attributes, which is why it ends up smaller.
When shortening ids is risky: if CSS, JavaScript or another SVG on the page points at an element by id (#icon-star), Maximum mode breaks that link. Use Safe for sprite sheets and for SVGs referenced through <use>.
Decimal places
This sets how many digits of each coordinate are kept. The default of 3 is visually identical. A 24×24 icon is often fine with 1 or 2, but dropping a large illustration to 0 can visibly shift curves. Below the results you will find a render comparison: both SVGs are drawn at the same size, and if more than 0.5% of pixels differ the tool warns that the shape may have changed.
Why scripts are removed
An SVG is both an image and a document, so it can contain <script>, event attributes such as onclick, and javascript: links. Serving user-uploaded SVGs as they are opens an XSS path. When the tool finds these in the original it warns you, and by default applies Remove scripts and event attributes and Remove external image and link references (images, use and @import pointing to http(s):// or //). The preview draws the SVG only through an <img>, so scripts in an uploaded file never run on this page.
Tips for the web
- Keep the
viewBoxon icons and logos. Without it, resizing with CSS distorts the proportions. - A small SVG can go into your CSS as a data URI to save a request. The URL-encoded form only escapes
%,#,<,>and", so it is usually shorter than base64. The 24×24 star icon (128 bytes) becomes 198 characters in base64 and 171 characters URL-encoded. - If the SVG needs an accessible name, keep its
<title>(in Custom mode leaveremoveTitleoff).
Related tools
To turn an SVG into PNG or JPG use SVG to PNG; to encode an image as Base64 use Image to Base64. For tidying the code you paste around it, see CSS Beautifier & Minifier and HTML Beautifier & Minifier.
Your files and code are processed only in your browser and are never sent to a server.