SVG Optimizer screenshot

SVG Optimizer

Strip editor metadata and collapse whitespace from SVG markup.

Privacy First
0 Runs
Updated 2026-11-07
Runs in your browser
No upload
No account needed
Updates as you type

Strip editor metadata and collapse whitespace from SVG markup. Enter your numbers and get an instant result.

Paste SVG markup and the page strips what editors leave behind: comments, the XML declaration, Inkscape and sodipodi namespace attributes, and the whitespace between elements. It then reports the byte size before and after and the percentage saved.

It is a cleanup, not an optimiser. Path data is not rewritten, groups are not merged, coordinates are not rounded and unused definitions are not removed. An SVG that shrinks a lot here was carrying editor metadata rather than vector data.

The output is the same drawing with less text around it. Nothing is validated, so malformed markup is cleaned as text and returned as malformed markup; the page does not tell you whether the result renders.

What is removed

Comments are deleted whole, including conditional comments an editor may have used. The XML prolog is removed because an inline SVG does not need it, and the Inkscape and sodipodi declarations and attributes are removed because they describe the editing session rather than the drawing.

Runs of whitespace collapse to one space and the whitespace between a closing and an opening tag is removed, which is where most of the saving comes from in a hand-indented file. Text content is not otherwise rewritten.

  • Comments and the XML declaration
  • Inkscape and sodipodi namespaces and attributes
  • Runs of whitespace and inter-element gaps

What it will not do

The page does not parse the document, so it cannot tell a presentation attribute from text that merely looks like one. A comment-like sequence inside a CDATA block is not a comment, and this naive pass would still remove it.

Optimisations that change the geometry, such as rounding coordinates or converting shapes to paths, are deliberately absent. Those need a parser and a decision about tolerance, and a wrong decision is a visibly different drawing.

How to use the two panels

Paste the markup into the Raw SVG panel; the Optimized SVG panel rewrites on every keystroke with no button to press. Read the byte sizes above the output and the percentage saved to see whether the file was carrying editor metadata.

Copy the cleaned markup out once the saving stops moving: a file that barely shrinks has little metadata left to remove. Check any text element afterwards, since whitespace that separated two words is collapsed by the same pass.

What to Expect

Best for

  • Removing editor metadata from an exported SVG
  • Cutting the whitespace from a hand-indented file
  • A quick size comparison before and after cleanup

Not ideal for

  • Path simplification or coordinate rounding
  • Merging groups or removing unused definitions
  • Validating that the result still renders

What this tool keeps

  • Every element and attribute that is not on the removal list
  • Path data, coordinates and colours exactly as written
  • The drawing's geometry, since nothing is re-computed

What may need cleanup

  • Malformed markup, which is cleaned but not repaired
  • Editor-specific attributes outside the two namespaces handled
  • Whitespace that was meaningful inside a text element

Common errors

  • Expecting a large saving from an SVG that has no editor metadata
  • Pasting broken markup and assuming the output is valid because it returned
  • Removing whitespace that separated two words in a text element

Example use cases

  • Cleaning an Inkscape export for a web page
  • Comparing the cost of editor metadata
  • Preparing an icon before hand-editing it

Sample input

An SVG with an XML declaration, one editor comment, Inkscape and sodipodi attributes, and indentation between elements.

Sample output

The same drawing on one line without the declaration, the comment or the editor attributes, with the byte sizes and percentage saved.

Who this is for

  • Front-end developers shipping SVG
  • Designers cleaning an export
  • Anyone comparing two versions of an icon

Frequently asked questions

What does the SVG optimiser remove?

Comments, the XML declaration, Inkscape and sodipodi namespace attributes, and the whitespace between elements, then reports the bytes saved.

Does it simplify paths or merge groups?

No. Path simplification, coordinate rounding and group merging are not performed.

Does it validate that the result still renders?

No. It strips what editors leave behind but does not validate the output.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.