The Magic Codex

SVG Compressor

Paste SVG markup and shrink it instantly — comments, whitespace, and empty attributes stripped, validity checked, exact bytes saved. Copy or download the minified SVG. Free, private, no signup.

0
bytes before
0
bytes after
0%
saved
Paste SVG above to compress it.

How to compress an SVG file

SVG files are XML text, which makes them wonderfully compressible: vector editors routinely export files where a third of the bytes are indentation, comments, and metadata. Minifying removes the bytes that don't affect rendering.

  1. Paste your SVG markup above. Copy it straight from your editor or from the .svg file (open it in a text editor, not an image viewer).
  2. Watch the stats. Before/after byte counts and the percentage saved update live as you type.
  3. Check the badge. The output is parsed as XML — green means it is still a valid SVG.
  4. Copy or download. The minified SVG renders identically to the original.

What gets removed

XML comments (<!-- ... -->), which editors use for notes and license blocks. Whitespace between tags — newlines and indentation separating elements. Empty attributes like id="" or class="", which carry no information. Everything else — path data, colors, transforms, and text content — is preserved character for character.

When compression matters most

Small icons and badges embedded directly in HTML pages benefit the most: the SVG travels with the page on every load, so every saved byte counts. For large illustrations, also consider enabling gzip or Brotli on your server — text compresses dramatically on top of minification.

What does SVG compression do?
SVG compression removes bytes that don't change how the image looks: XML comments, whitespace between tags, and empty attributes. The drawing itself — shapes, colors, positions — is untouched, so the image renders identically at a smaller size.
Is minified SVG still editable?
Yes, but it's harder to read — everything sits on one or two lines. Keep your original commented version as the master copy, and treat the minified file as the published copy you upload to your website.
Why does my SVG export have so much bloat?
Vector editors like Inkscape and Illustrator add editor metadata, long decimal numbers, comments, and their own XML namespaces so the file round-trips back into the editor. Browsers ignore almost all of it — this tool strips the comments, whitespace, and empty attributes safely.
How is the file size measured?
Sizes are counted in UTF-8 bytes — the real number of bytes sent over the network — not characters. The percentage saved is computed from those byte counts before rounding, so it's exact.
What does the validity check do?
After minifying, the tool parses the result as XML and confirms every tag is balanced and properly nested. If the check fails, the output is still shown for inspection, but the badge warns you instead of silently handing you a broken file.
Does this change my image's appearance?
No. Only comments, inter-tag whitespace, and empty attributes are removed. Shape data, colors, transforms, and text content are never touched, so the compressed SVG renders pixel-identical to the original.

More from the codex

Questions about this tool?

Compressed file look wrong or have a suggestion? Email [email protected] — every message is read by the indie dev behind the codex.