Skip to content

SVG minifier

Shrink SVG markup by stripping XML cruft, comments and editor metadata.

Input
Output

SVG minifier

Paste an SVG exported from Illustrator, Inkscape or Figma and this tool returns a minified version with the same appearance and a much smaller file size. It removes the XML declaration, comments, editor-only metadata (Inkscape's and Illustrator's namespaced elements and attributes), empty groups and the whitespace between tags — all things a browser or an <img> tag never needed in the first place.

Decimal places controls how many digits coordinates and other numeric attributes keep, so "12.34567" becomes "12.35" at the default of two. Remove id and class attributes drops both, except an id still targeted by a url(#…) fill or an href="#…" reference — those stay, so gradients, clip paths and <use> elements keep working. Remove width/height, keep viewBox strips the outer dimensions only when a viewBox is present to take over sizing, so the SVG still scales correctly. Shorten hex colors turns "#ffffff" into "#fff" wherever all three channels double up, leaving anything else untouched.

Malformed markup — an unclosed or mismatched tag — is reported as an error instead of guessed at, since a minifier that silently patches broken XML can change what renders. Text inside <text>, <tspan> and inline <style> stays exactly as written, since whitespace there is part of the content, not formatting. Windows and Unix line endings are handled the same way, and the live tally shows bytes in, bytes out and the percentage saved.

Everything runs locally in your browser: the SVG never leaves your device, which matters for unpublished icon sets and client artwork. Copy the result, download it as a .txt file, or send it back into the input to apply another pass with different options.

FAQ

Will this change how the SVG looks?
No. It only removes markup that has no visual effect — comments, metadata, empty groups and extra whitespace — and rounds coordinates, which changes rendering by less than a pixel at the default precision.
Is it safe to remove ids and classes?
The tool keeps any id that is still referenced by a url(#…) fill/stroke or an href="#…" link, so gradients, clip paths and reused icons keep working. Only unreferenced ids and all classes are removed.
What happens if my SVG has a syntax error?
The tool reports it instead of guessing — an unclosed or mismatched tag returns a calm error message so you can fix the markup and try again.
Does removing width and height break the image?
Only when a viewBox is present does the tool drop them — the viewBox alone is enough for the SVG to scale to whatever size its container gives it.
Is my SVG uploaded anywhere?
No. Minification runs entirely in your browser — your file never leaves your device.