SVG Optimizer
Paste an SVG (for example straight out of a vector editor) and get a leaner version. Runs entirely on your device. Minify mode produces a single-line document with collapsed whitespace; pretty mode re-indents it to 2 spaces. Numeric attributes are rounded to a configurable precision, XML comments and truly empty <g> groups can be stripped, and no colour values, paths or other meaning are changed — only the document is re-serialized. The size before and after is reported so you can see what changed.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
What minify and pretty really change
Minify collapses whitespace between tags and emits the whole document on one line; pretty reindents it at two spaces per level. Neither reorders attributes nor rewrites path data — the difference is serialization only, and the reported before/after size shows exactly what the whitespace removal saved you.
Rounding numbers without touching colours
“Decimal precision” rounds standalone numeric tokens inside attribute values — coordinates in d, x, y, width, plus transform matrices — to between 0 and 6 decimals. Hex colours such as #fff, rgb() triples, identifiers and unit-suffixed values are recognised and skipped, so geometry tidies up without a fill silently shifting.
Comments and empty groups
“Remove comments” deletes XML comments, the annotations vector editors leave behind, while “Remove empty <g> elements” strips groups with no drawable children. Groups carrying attributes or real content are kept, so structure that affects rendering survives the pass intact.
Loud failure on broken input
If the opening <svg> element is missing or the tags are unbalanced the optimizer reports an error instead of emitting a broken file, and anything beyond two million characters is refused. Parsing and re-serialization both happen in the browser, so the artwork you paste is never uploaded.
Questions
Does it change how the SVG looks?
No. Only the serialization changes: whitespace between tags, comments (when enabled), empty <g> groups and numeric precision. Colours, paths and attribute values keep their meaning. "none" fills and stroke remain untouched.
What does rounding do to attributes?
Numeric tokens in attribute values (geometry, transform matrices that are present, coordinates) are rounded to the chosen precision. Colour values (hex like #fff or rgb(...)), identifiers and unit suffixes are left alone.
Is minified output safe to inline in HTML?
Yes — a single-line SVG is generally the most bandwidth-friendly for inlining. If any browser parser has issues with your exact file you can switch to pretty mode for a readable diff first.
Does it handle malformed SVG?
It reports a clear error if the opening <svg> element is missing or tags are unbalanced, rather than emitting a broken document.
Related tools
See categorySVG to JSX / React Component
Convert SVG or XML markup into JSX — camelCased attributes, style objects, optional component.
Data URI Converter
Encode text or an image as a data: URI, or decode a data: URI back to text or an image file.
HTML Prettifier
Beautify HTML output — indented tags, one attribute per line for long tags, preserved text.
CSS Minifier
Minify CSS: strip comments, collapse whitespace, drop empty rules and extra semicolons.