Compress SVG Code
Strip comments, the XML declaration and redundant whitespace from SVG markup without touching a single path.
Whitespace and comments, nothing else
Paste SVG markup and the page removes the XML declaration, comment blocks and <metadata> when you ask for it, collapses the gaps between tags and reduces runs of whitespace inside a tag to one space. It prints the minified markup and the byte count saved. No path, coordinate or attribute is rewritten.
The bodies of <text>, <tspan>, <style> and <script> are lifted out before the pass and put back untouched, because white space there is content and collapsing it would change the picture or the stylesheet. The page says how many blocks it protected. A pasted document with no < is refused, since there is nothing to minify in plain text.
The pass is string work in this tab. Nothing is uploaded, no file is stored, and the same markup always prints the same output.
Minify SVG markup by removing comments, the XML declaration, `<metadata>` and redundant whitespace, with the bytes saved reported against the input.
It is a whitespace pass, not an optimiser: no path is rewritten and no attribute is dropped, so the geometry is exactly what you pasted.
How to use Compress SVG Code
Paste the SVG markup into the input box and set Drop the XML declaration and Drop <metadata> to yes or no.
Press Run and read the minified SVG, with the byte count saved printed beside the output.
Use Copy to take the minified markup, or Download to keep it as a file.
What is protected, and why
The bodies of `<text>`, `<tspan>`, `<style>` and `<script>` are lifted out before the pass and put back byte-for-byte. White space inside a text element is drawn, and white space inside a stylesheet can change a selector, so collapsing either would change the output rather than shrink it. The answer says how many blocks were protected.
A turn of extra space inside a tag is safe to remove because the parser ignores it. A space between two elements is safe to remove for the same reason. Anything else — a path command, a transform matrix, a numeric attribute — is left exactly as written.
What to Expect
Best for
- Shrinking an icon set or an inline illustration before pasting it into a page.
- Removing editor comments from a designer export.
What this tool keeps
- The markup never leaves this tab and nothing is stored, so the page works offline and retains no copy of your artwork.
Sample input
<?xml version="1.0"?><!-- icon --><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"> <metadata>junk</metadata> <rect x="0" y="0" width="10" height="10" /> <text x="1" y="9">a b</text> <!-- tail --></svg>
Sample output
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><rect x="0" y="0" width="10" height="10" /><text x="1" y="9">a b</text></svg> Saved 82 of 220 bytes (37.3%). 1 <text>, <style> or <script> block was left byte-for-byte intact: white space inside them is content, so collapsing it would change the picture.
Frequently asked questions
What exactly gets removed?
The XML declaration, comment blocks, <metadata> and <!DOCTYPE> when you leave those options on, the whitespace between tags, and runs of whitespace inside a tag. No path, coordinate or attribute value is touched.
Why does the byte count sometimes shrink by very little?
A hand-written SVG with little indentation has little whitespace to remove. The comment reports the exact bytes saved, and a dense one-line file can legitimately save nothing.
Is my SVG uploaded?
No. The pass is string work in this tab. Nothing is sent anywhere, no file is stored, and the same markup prints the same output after a reload.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.