⚡ BreezyTools Pro — Ad-free experience across all 200+ tools. Less than a coffee a month → Learn More

SVG Compressor

Reduce SVG file size with safe browser-based cleanup presets. No upload, no server, no hidden processing.

Original0 B
Compressed0 B
Saved0%
Ready. Paste SVG markup or upload a file to compress it.

What the SVG compressor removes

SVGs exported from design tools carry markup the browser never draws: an XML declaration, generator comments, embedded metadata, editor namespace declarations, and indentation. This tool strips that markup with text-based rules, entirely in your browser.

Every preset removes the <?xml ... ?> declaration, comments, the <metadata> and <desc> elements, and editor-only markup from Inkscape, Sodipodi, and Affinity (their elements, attributes, and namespace declarations). <title> is kept because it's the graphic's accessible name, and xmlns:xlink is kept whenever the file still uses xlink:href, so the output stays valid XML. The presets differ in what they do after that:

  • Safe: only the removals above. Whitespace and numbers stay as they are.
  • Balanced (default): also removes empty <g> groups, spaces around = in attributes, whitespace between tags, and repeated spaces.
  • Aggressive: everything in Balanced, plus rounding every decimal number to two places. This saves a lot on files whose path data uses long decimals.

How to compress an SVG

  1. Upload an .svg file, which compresses right away, or paste markup and click Compress SVG.
  2. Switch presets and compress again to compare the Original, Compressed, and Saved figures.
  3. Copy the result or download compressed.svg. Then open it in a browser to confirm it looks the same.

Before and after

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generator: design tool export -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
  <title>Arrow</title>
  <g></g>
  <path d="M4.000000 12.500000 L19.333333 12.500000" stroke="#000" />
</svg>

The Aggressive preset turns that into:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>Arrow</title><path d="M4 12.5 L19.33 12.5" stroke="#000" /></svg>

Lossless vs. lossy: what decimal rounding changes

Safe and Balanced never change coordinates. Aggressive is lossy in a controlled way: 12.34567 becomes 12.35. Whether that's visible depends on the size of the viewBox, not on how large the graphic is displayed.

  • In a 24×24 icon, two decimals move points by at most 0.005 units, which is invisible even when the icon is scaled up.
  • Illustrations with viewBoxes hundreds or thousands of units wide tolerate rounding easily.
  • Tiny coordinate systems, such as viewBox="0 0 1 1" or gradients defined in fractions, can shift visibly. Use Safe or Balanced for those.

Rounding applies to every decimal in the file, including numbers in inline styles and text.

When to be careful

  • Accessible inline SVGs. Every preset keeps <title> but removes <desc>. If an inline SVG relies on its description, use the SVG Optimizer, where metadata removal can be switched off.
  • Prefixed attributes. Editor attributes such as inkscape:label and serif:id are removed together with their namespace, and xmlns:xlink is only removed when no xlink:href remains, so the file stays well-formed. Other custom namespaces are left untouched.
  • Meaningful spaces in text. Balanced and Aggressive delete whitespace that sits alone between two tags, so a space between two <tspan> elements disappears.
  • Master files. Keep the original for editing. The compressed file is for shipping.

Servers usually send SVG gzip- or Brotli-compressed, so the savings on the wire are smaller than the raw percentage shown above. Removing unused markup still helps, especially for SVGs inlined into HTML or JavaScript.

Frequently Asked Questions

Is SVG compression lossless?

With the Safe and Balanced presets, yes for geometry: they remove markup that isn't drawn and leave coordinates untouched. Aggressive rounds numbers to two decimal places, which is invisible for typical icons and illustrations but can matter for very small coordinate systems.

How much smaller will my SVG get?

It depends on how much editor overhead the file carries. Exports full of metadata, comments, and six-digit decimals often shrink a lot. Hand-written or already-optimized SVGs may barely change, because this tool doesn't rewrite path data, merge shapes, or shorten IDs and colors.

Why won't my compressed SVG open?

Browsers parse standalone SVG files as strict XML, so any leftover syntax error stops them loading. The compressor keeps every namespace declaration that's still in use, so this is rare; if it happens, the original file usually had the problem already. Open the original in a browser to check, try the Safe preset, or re-export a plain SVG from your editor.

Does compressing an SVG reduce image quality?

No. An SVG is drawn from vector instructions, so removing markup changes nothing you can see. The only step that touches geometry is Aggressive decimal rounding, and at two decimals it's rarely noticeable.

Should I serve SVGZ files instead?

SVGZ is a gzip-compressed SVG, and it must be served with a Content-Encoding: gzip header to display. It's usually simpler to serve plain .svg files and let your server or CDN compress them, which gives the same transfer savings.

Is my SVG uploaded anywhere?

No. Compression runs in your browser with JavaScript, and the file never leaves your device.

Love using BreezyTools?

Go Pro for an ad-free experience, priority features, and support independent development — for less than a coffee a month.

Upgrade to Pro →