Skip to content

SVG Optimizer - Minify SVG Online with SVGO

or paste SVG code below
Options

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

Frequently Asked Questions

What does the SVG optimiser remove?
It runs SVGO's default preset: the XML declaration, comments, editor metadata and namespaces (Illustrator, Inkscape, Sketch), empty groups, unused gradients and other definitions, and attributes that only repeat the default. It also rounds numbers, shortens path data and, with the options on, merges paths and turns shapes into paths. Exports from design tools commonly shrink by half or more; a hand-tuned icon may barely change.
Can optimising break my SVG?
It can, in a few known ways. Clean up IDs renames or drops IDs your CSS or JavaScript may target. Merge paths joins shapes you might want to animate separately. A precision of 0 or 1 visibly distorts small icons. Compare the before and after previews, and turn off the option that caused the change.
Should I keep the viewBox?
Almost always. The viewBox defines the SVG's internal coordinate system, which is what lets it scale to whatever width and height CSS gives it. Without it, a 24 by 24 icon set to 48px wide is cropped or stays small. It costs about 20 bytes, so Remove viewBox is off by default.
Why show the gzipped size?
Servers and CDNs send SVG compressed with gzip or Brotli, so the gzipped figure is closer to what visitors download. Shortening IDs or attribute names saves little once compressed, because gzip already handles repeated strings. Dropping metadata blocks and rounding long decimals saves a lot in both.
How do I use an SVG as a CSS background?
Use the CSS background tab. It gives a background-image rule with the SVG as a data URI. Only the characters that must be escaped (such as <, >, # and %) are percent-encoded, and double quotes become single quotes, so the result is smaller than base64 and still readable.
Is my SVG uploaded?
No. SVGO runs in your browser, so the file never leaves your device.