Category: Developer tools
SVG Minifier
Strip XML and SVG comments, drop whitespace between tags, tidy spaces around equals signs
Paste SVG markup and remove XML comments, whitespace between tags and spaces around equals signs. Copy the compact SVG and compare byte sizes, all in your browser.
<svg width="120" height="80" viewBox="0 0 120 80" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="12" fill="#0f766e" /><text x="20" y="46" fill="white">SVG</text></svg>
Everything on this page is processed in your browser. Nothing is uploaded.
What this tool does
This is a markup-level SVG minifier, and the distinction matters. Paste SVG and it removes XML and SVG comments, deletes the whitespace between tags, collapses repeated whitespace and trims the spaces around equals signs in attributes. You get compact markup, the input and output sizes in UTF-8 bytes, a copy action, and sample and clear buttons. What it deliberately does not do is the work an SVG optimizer does. There is no structural optimization: paths are not simplified, coordinates are not rounded and numeric precision is not reduced. Metadata, hidden elements, unused definitions, editor data and accessibility attributes are all left exactly where they are. There is no SVG validation, no rendering preview, no file upload and no PNG conversion. That is the point: geometry, IDs, viewBox and attributes come out unchanged, and only comment and whitespace bytes disappear, so the graphic renders as it did before. The one thing worth checking afterwards is whitespace-sensitive SVG text content, where spacing is part of what the reader sees. Pasted SVG markup and the compact output stay in your browser and are never uploaded to LocalTools.
How to use it
- Paste your SVG markup into the input area, or load the sample to see what changes.
- XML and SVG comments are removed, whitespace between tags goes, repeated whitespace collapses and spaces around equals signs are trimmed.
- Compare the byte sizes, copy the compact SVG, then review any text content inside the graphic.
Privacy
This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.
Frequently asked questions
- What does SVG minify do here?
- It removes XML and SVG comments, the whitespace between tags and repeated whitespace, and it trims the spaces around equals signs in attributes. Nothing else in the file is touched.
- SVG minify vs optimize: what is the difference?
- Minifying is a text operation on the markup. Optimizing rewrites the drawing: simplifying paths, rounding coordinates, dropping metadata and unused defs. This tool only minifies, so it never changes geometry or precision.
- Can minifying break an SVG?
- Geometry, IDs, viewBox and attributes survive untouched, so the graphic should render identically. The exception is whitespace-sensitive text content inside the SVG, where spacing is visible output and deserves a quick review.
- Why minify SVG at all?
- Exported SVGs carry editor comments and generous indentation that no browser needs. Removing them shrinks the file with zero visual risk, and the UTF-8 byte comparison shows exactly how much you saved.
- Is SVG minification the same as SVG compression?
- No. Minifying deletes characters from the markup. gzip, Brotli and SVGZ compress the byte stream at the server or CDN layer, and neither is produced here. There is also no file upload and no PNG conversion.