Make SVG files smaller by removing editor data, comments and extra precision. Scripts and event handlers are removed by default. Everything runs locally in your browser.
Drop an SVG file here or click to choose
Or paste SVG code below
Before
After
SVG files exported from design tools carry a lot of data that browsers do not need: editor settings, comments, metadata blocks, empty groups and numbers with many decimal places. This tool removes that data and shows the size before and after, with a preview of both versions.
The optimizer runs in your browser. Your SVG is never uploaded, which matters when the file is an unreleased logo, a client's artwork or an internal diagram.
.svg file.| Option | What it removes or changes |
|---|---|
| Remove comments | <!-- --> comments, which are never shown. |
| Remove XML declaration and DOCTYPE | The <?xml ?> line and
DOCTYPE. Browsers do not need them for inline or linked SVG. |
| Remove <metadata> | Licence, author and RDF blocks that some editors add. |
| Remove editor data | Inkscape, Sketch and Illustrator namespaces and attributes, such as layer names and guide positions. |
| Remove empty groups and attributes | <g> elements with no content
and attributes with empty values. |
| Collapse whitespace | Indentation and line breaks between tags. |
| Keep <title> and <desc> | On by default. These describe the image to screen readers, so keep them for accessible icons and illustrations. |
| Remove scripts and event handlers | <script> elements,
on* attributes and javascript: links. |
| Remove unused ids | Off by default. Removes ids that nothing in the file refers to. Leave it off if CSS or JavaScript on your page targets those ids. |
| Number precision | Rounds coordinates to the chosen number of decimals. Three is a safe default for most icons. |
It depends on where the file came from. Icons exported from design tools often shrink by 30 to 60 percent, because editor data and long decimal numbers make up much of the file. Files that were hand-written or already optimized shrink very little. The size shown after optimizing is the real difference, measured on the output text.
If the file will be served from a web server, it will usually also be compressed with gzip or Brotli on the way to the browser. Optimizing first still helps, because there is less data to compress and less for the browser to parse.
SVG is a document format, not just an image. It can contain scripts and links that run when the file is opened directly or placed inline in a page. If you accept SVG uploads from other people, or you are using an icon from an unknown source, keep "Remove scripts and event handlers" switched on. The preview on this page uses an image element, which never runs scripts, so checking an unknown file here is safe.
url(#id) or href="#id" are always kept.viewBox, style attributes and <style> elements
are never removed.on* event handlers and javascript: links are removed by default.
Turn this off only for files you trust.No. The file is read and optimized in this tab. Nothing is sent to a server.
The most common cause is number precision. Rounding coordinates to fewer decimals can move points in small or detailed shapes. Choose a higher precision, or turn rounding off, and optimize again.
Style attributes and <style> elements are never removed, and ids that the file
refers to are kept. If your page's own CSS or JavaScript targets ids inside the SVG, leave "Remove
unused ids" switched off.
Yes for meaningful images such as illustrations and icons that convey information, because screen readers use them. For purely decorative icons, they can go, as long as the page marks the icon as decorative.
This tool keeps the file as SVG. To create a small inline version of an image, see Image ↔ Base64, and to compress raster images use the Image Optimizer.
Back to all tools.