SVG Optimizer

Shrink SVG files by removing comments, metadata and editor data, rounding numbers and minifying paths, with a live before/after preview and an SVG to PNG export. Runs in your browser.

About this tool

SVG files exported from Inkscape, Illustrator, Sketch or Figma usually carry a lot that no browser draws: editor namespaces, a metadata block, comments, empty layers, long decimal numbers and indented whitespace. This tool parses your SVG in the browser, strips that bookkeeping, rounds the numbers to the precision you choose and minifies the path data, then shows the before and after size with a side-by-side preview so you can see that nothing visible changed. It can also draw the SVG to a PNG at any width up to 8192 px. The clean-up is deliberately conservative: it does not merge paths, convert shapes to paths or bake transforms, so it rarely changes how an image looks. Everything runs in your browser and the SVG is never uploaded.

How to use it

  1. Drop an .svg file onto the upload box, or paste the SVG code into the text area. Load sample shows an Inkscape-style file with comments, editor data and long decimals.
  2. Check the optimizations on the left. The defaults remove comments, metadata, editor data and empty groups, minify whitespace and path data, and round numbers to 3 decimal places. Turn on the optional ones (remove title and desc, remove unused IDs) if you know you can.
  3. Compare the Original and Optimized previews and read the size line above them. If something looks different, raise the number precision or switch off the option you suspect and the result updates immediately.
  4. Click Copy or Download .svg to take the optimized file. To get a raster image instead, set the PNG width (or pick 1x, 2x or 4x), choose a transparent, white or custom background, and click Download PNG.

FAQ

Will optimizing change how my SVG looks?

With the default settings it should not, because it only removes things that are not drawn (comments, metadata, editor namespaces, empty groups) and tightens whitespace. Rounding numbers is the one lossy step: 3 decimal places is invisible at normal sizes, but a very small icon scaled up a lot can show differences at 0 or 1 decimal places. The Original and Optimized previews sit side by side so you can check.

What does it remove exactly?

Comments, the XML declaration and DOCTYPE, the metadata element, elements and attributes from editor namespaces (Inkscape, Sodipodi, Illustrator, Sketch, Affinity, RDF and Creative Commons data), enable-background and data-name attributes, the version attribute, empty groups and defs, and groups with no attributes (their children are moved up one level). Whitespace between elements and inside path data is collapsed. The viewBox is never touched.

Why are paths with arcs not rounded?

In path data, the two flags of an arc command can be written with no space between them (for example "a1 1 0 011 1"). Rounding or re-spacing that text by pattern could corrupt the arc, so paths that contain an arc command keep their original numbers and only have extra whitespace collapsed. Paths made of lines and curves are fully rounded.

Is it safe to open an SVG I do not trust?

Yes. The SVG is parsed into a document that is never attached to the page, script elements, on-event attributes and javascript: links are always removed from the output, and the previews use image elements, which never run scripts. The tool tells you when it removed any. You should still review an untrusted SVG before putting it on your own site.

Should I remove unused IDs or the title and desc elements?

Both are off by default on purpose. Unused IDs can still be targeted by CSS or JavaScript on the page that inlines the SVG, and the tool cannot see that code. Title and desc are what screen readers announce for an inline SVG, so removing them can hurt accessibility. Turn them on for decorative icons you control.

How does the SVG to PNG export work?

The tool gives the SVG an explicit width and height at the pixel size you choose and lets your browser draw it onto a canvas, so the result is sharp rather than an enlarged bitmap. The height follows the SVG aspect ratio, the maximum is 8192 px, and the background can be transparent, white or a colour you pick. Images and web fonts that the SVG loads from other URLs are not loaded when it is drawn this way, so text in a web font may appear in a fallback font.

How is this different from SVGO or Image Compressor?

SVGO is the widely used open-source optimizer with many more plugins, such as merging paths and converting shapes, and is the better choice inside a build pipeline. This page is a quick, private, no-install clean-up with a visual before and after. Image Compressor handles JPG, PNG and WebP, which are raster formats; SVG is text and is shrunk by editing that text, which is what this tool does.

Related tools

Guides & comparisons

← All tools · Image Tools · Blog · Cheat sheets · FAQ