SVG optimizer (safe minifier)

Minify SVG safely, compare before and after pixels, and see the size and gzip savings.

What to do

3 suits icons; use 1 or 2 for large illustrations, 4 or more for tiny or heavily scaled drawings.

Turn off if page CSS or JavaScript outside this file targets IDs inside it.

Off by default: screen readers read the title.

Off by default: it rarely saves much and changes what CSS selectors like rect match.

Size

Paste SVG code or open a file.

What this tool does

Paste SVG code or open an .svg file and get a smaller file that draws the same picture. Exported SVGs carry a lot that browsers never use: comments, editor settings (Inkscape's named view, Illustrator and Sketch data), metadata blocks, numbers with six decimals, attributes set to their default values and IDs nothing points to. The optimiser removes them, rounds numbers to the precision you choose and shortens path data, then draws both versions in your browser and compares them pixel by pixel, so you know the result is safe before you use it. It shows the size before and after, raw and gzipped, and lists what it changed. Everything runs on this page.

Safe by design

Most broken optimised SVGs come from a handful of "optimisations" that are only usually safe. This tool applies each step only when the file gives it no way to matter:

  • Default attributes such as fill="black" are removed only when no parent sets that property, there is no <style> block that could, and the element is not inside <defs> or a <symbol>: a <use> passes its own fill to what it shows, so a "default" fill there is doing real work.
  • IDs are removed only when nothing refers to them: not an href, not url(#…) in an attribute, a style or CSS, not a selector in a <style> block, not an animation's begin, not an ARIA attribute. Files with a <script> keep every ID, and <symbol> IDs always stay, because sprite sheets are used from outside the file. If your page's CSS or JavaScript targets IDs inside the SVG, turn the option off.
  • Whitespace is removed between tags but never inside <text>, <tspan>, <title>, <style> or anything marked xml:space="preserve".
  • Numbers are rounded with drift correction: on a long path of relative steps, each step is written as the difference from where the rounded path already is, so errors cannot add up. viewBox and the root size are never rounded.
  • Converting shapes to paths is off by default: it rarely saves much, and CSS that selects rect or circle would stop matching.

The article on optimising SVGs safely explains each of these with an example that breaks.

Reading the results

  • Size shows bytes before and after, and the gzip size: what a server actually sends when compression is on. Gzip already removes much of the repetition, so the gzip saving is usually smaller than the raw one; it is the honest number for web performance.
  • What was changed lists comments, metadata, editor elements and attributes, shortened numbers, default attributes, unused IDs and definitions, and groups removed.
  • The pixel check draws both versions at up to 512 pixels with this browser's own renderer and compares every pixel. "Pixel-identical" means no pixel changed; "visually identical" means only anti-aliasing at a few edges moved by a few levels, which rounding coordinates by a thousandth of a unit can do. If the pictures differ, raise the decimals or turn an option off.

Choosing the precision

Three decimals suit icons drawn on a 24 or 48 unit grid: a thousandth of a unit is far below a pixel at any normal size. Large illustrations with a viewBox of several thousand units can use one or two decimals. Keep four or more for tiny viewBoxes (0 to 1) or drawings that will be scaled up a lot.

To turn an SVG into PNG or JPG, or a picture into a favicon, use the SVG converter and the favicon generator. To check how much gzip saves on any text, the code minifier shows the same numbers for HTML, CSS and JavaScript.

Frequently asked questions

Is my SVG uploaded?

No. It is parsed, optimised and drawn in your browser. The previews are shown as images, so scripts inside the SVG never run.

Will the optimised SVG look the same?

The tool checks: it draws both versions and compares every pixel. With the default settings, icons and illustrations come out pixel-identical or differ only in anti-aliasing at a few edges.

Why did my icon lose its colour in a sprite?

Some optimisers remove fill="black" from paths inside <symbol>, but a <use> element passes its own fill down, so that default was doing work. This tool keeps default attributes inside <defs> and <symbol>.

Should I remove <title>?

Usually not. Screen readers read the title of an SVG used as an image or inline. The option is off by default.

How is this different from SVGO?

SVGO is a thorough command-line optimiser with many more transformations. This tool does a smaller set conservatively, checks the pixels, and runs without installing anything.