Tool guide
About this tool.
- Reduces SVG file size and eliminates redundant XML metadata, comments, editor namespaces and whitespace while strictly preserving viewboxes, element IDs, class names and accessibility tags.
- Use when exporting vector graphics from Figma, Illustrator or Sketch before embedding them in web applications, inline React components, or CSS.
Paste raw SVG markup into the text area or run on active editor selection.
Run the optimizer to parse and sanitize the vector document.
Review the savings summary (UTF-8 bytes before and after).
Copy clean SVG markup or download optimized.svg.
- <!-- icon --><metadata>editor data</metadata> inside <svg> → both removed.
- <?xml version="1.0" encoding="UTF-8"?> and an Illustrator <!-- Generator: … --> comment before <svg> → both removed.
- inkscape:version="1.2" and xmlns:inkscape="…" → removed, and so are xmlns:sketch and sketch:type; xmlns:foo and foo:bar from other namespaces stay.
- viewBox="0 0 24.000 24.000" → viewBox="0 0 24 24", and stroke-width="1.500" → stroke-width="1.5".
- <text>Version 2.0</text> and id="icon-1.0" → copied unchanged, because only numeric attributes are trimmed.
- <path id="mark" class="icon" aria-label="Mark" d="M 2 2 L 22 22" /> → the same element with id, class and aria-label, closed as "/>".
- The Icon with editor metadata sample → one line of SVG and the summary SVG optimized: 195 to 149 bytes (24% smaller).
- <div><svg></svg></div> → error: Paste valid SVG markup starting with <svg>.
- Optimization runs locally, tag by tag, without a full XML parser. Text content, CDATA and the values of non-numeric attributes are copied unchanged.
- Trailing zeros are trimmed only in numeric attributes such as d, points, viewBox, x, width and stroke-width.
- Critical visual attributes (viewBox, width, height, fill, stroke, transform) are preserved.
- Classes and IDs are retained to prevent breaking external CSS styles or JavaScript hooks.
- Malformed XML is not detected: unclosed tags pass through unchanged. Only input that does not start with <svg>, optionally after an XML declaration, comments or a doctype, is refused.
- Does not perform destructive path approximation or lossy coordinate truncation.