SVG Minifier

Minify SVG markup by removing extra whitespace.

Open tool

Overview

Paste SVG markup and the minifier strips comments, unnecessary whitespace, and editor metadata (Illustrator/Inkscape-specific attributes), producing a smaller file that renders identically. Conservative by default - no path data is rewritten, so visual output is byte-for-byte equivalent.

It's for developers shipping icons or illustrations as inline SVG or static assets, and designers exporting from a vector editor that leaves a lot of cruft behind. Reach for it when a 12KB icon ought to be 2KB, when sprite sheets get bloated, or when serving SVGs from a size-sensitive CDN.

How it works

SVG is an XML dialect defined by the W3C SVG 1.1/2 specs. The minifier walks the parsed tree and removes: XML comments, processing instructions, whitespace between elements (except inside <text> content), default-value attributes, and the namespaced metadata that vector editors leave behind (sodipodi:, inkscape:, xmlns:dc:).

Path d attributes are left untouched because rewriting them can subtly alter rendering. For deep path optimisation use a tool like SVGO with manual review.

Examples

  • Before:
    <?xml version="1.0"?>
    <!-- exported -->
    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" version="1.1">
      <path d="M0 0 L24 0 L24 24 L0 24 Z" fill="#000"/>
    </svg>
    
  • After:
    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M0 0 L24 0 L24 24 L0 24 Z"/></svg>
    
  • Inkscape metadata stripped:
    Removes sodipodi: and inkscape: attributes and namespaces.
    
  • Whitespace inside <text> preserved:
    <text>Hello   world</text>   -> preserved as-is
    

FAQ

Will the minified SVG render identically?

Yes - byte-equivalent visuals. Only whitespace, comments, and dead attributes are removed.

Should I use SVGO instead?

SVGO does deeper optimisation (path simplification, transform collapsing) and is the industry standard. Use this minifier when you want a safe, conservative pass without the risk of subtle visual changes.

Does it inline style="..." from <style> blocks?

No - styles are left where they are. Keep them in <style> for reusability or convert to attributes by hand if you prefer.

What about xmlns:xlink?

xlink:href is deprecated in SVG 2 (use href), but many parsers still require it for backward compatibility. The minifier leaves it alone.

Try SVG Minifier

An unhandled error has occurred. Reload ×