SVG Optimizer - Minify SVG Online with SVGO
Optimise SVG files with SVGO
SVGs exported from Illustrator, Figma, Inkscape or Sketch carry data the editor needs to reopen the file but the browser never uses: generator comments, layer IDs, metadata blocks and coordinates with six decimal places. This tool runs SVGO in your browser to strip that out, and shows a side-by-side preview with raw and gzipped sizes so you can check nothing changed.
Upload a file, click Paste SVG, or paste markup into the text box. Load demo fills in a messy Illustrator export to try it on. The result updates every time you change an option.
Example
A small Illustrator export (473 bytes):
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 27.0.0, SVG Export Plug-In -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="24px" height="24px" viewBox="0 0 24 24"
style="enable-background:new 0 0 24 24;" xml:space="preserve">
<style type="text/css">.st0{fill:#FF0000;}</style>
<rect x="2.000000" y="2.000000" class="st0" width="20.123456" height="20"/>
</svg> With the default options (156 bytes):
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="24" height="24" viewBox="0 0 24 24"><path d="M2 2h20.123v20H2z" style="fill:red"/></svg>
The declaration, comment, version, id, unused xlink namespace, x/y
and enable-background are gone. The <style> rule was moved onto the element, the rectangle became
a path, px units were dropped and the width was rounded to three decimals. xml:space is left in place.
What each option does
- Remove viewBox (off by default). The viewBox is what lets an SVG scale. Keep it for icons and anything sized with CSS.
- Remove width/height. Drops fixed dimensions so CSS controls the size. If there is no viewBox, one is created from the old width and height first.
- Remove <title> and <desc>. A title gives screen readers a name for the image, so only remove
it from decorative SVGs. With this off, boilerplate such as
<desc>Created with Sketch.</desc>is still removed. - Clean up IDs. Removes IDs nothing refers to and shortens the rest. Turn it off if CSS or JavaScript targets IDs inside the SVG, or if two inline SVGs on one page could end up with the same short ID.
- Merge paths. Joins neighbouring paths with the same attributes into one
<path>. Turn it off if you animate or colour paths separately. - Convert shapes to paths. Rewrites
<rect>,<line>and polygons as path data, which is usually shorter. - Inline styles. Moves
<style>rules onto the elements they match, so class names from two inline SVGs cannot clash on one page. - Number precision (0 to 8, default 3). Decimal places kept in coordinates. 2 or 3 is fine for most icons. Below that, check the preview for wobbly curves.
- Prettify. Indents the output for reading or editing. Leave it off for production.
Output formats
The tabs give you the optimised SVG, a data URI for url(), a ready-made background-image rule, and
a React component. The component uses JSX attribute names (className, strokeWidth) and spreads
its props onto the root <svg>, so <SvgIcon width={16} /> works. For other
markup, use HTML to JSX.
Related Tools
Image Compressor
Compress images in your browser with adjustable quality and format selection.
Image Resizer
Resize images to any dimension with aspect ratio lock and common presets.
Image to Base64
Convert images to Base64 strings, data URLs, and HTML img tags.
QR Code Generator
Generate QR codes for URLs, Wi-Fi, contacts, email, SMS, or phone with colours, logo, and PNG/SVG export.