SVG Optimizer
Free SVG optimizer: remove comments, editor data and extra whitespace from SVG code and see how many bytes you save. Runs in your browser.
Raw SVG
Stays in your browserCleaned SVG
Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)
Next steps
Done here? Use the Send to… menu on the result to carry it on to SVG to PNG.
Free Online SVG Cleaner & Minifier
Paste raw SVG markup — especially SVGs exported from design tools — to strip comments, editor metadata, and unwanted whitespace, leaving clean markup ready to drop into HTML or React. This SVG optimizer removes comments, editor data and extra spaces from SVG code. It helps frontend developers reduce inline SVG noise and file size before placing icons or illustrations in a production bundle.
Why SVGs need cleaning
SVG files exported from design tools like Inkscape, Illustrator, or Sketch are usually full of editor-specific metadata that has no visual effect but adds real file size: XML comments, a <metadata> block with Dublin Core/RDF information, and namespaced attributes like inkscape:label or sodipodi:type that only the originating tool understands. None of it affects how the SVG renders, but it does bloat the file and clutter the markup if you're pasting it directly into your codebase.
How to use this cleaner
Paste your raw SVG markup and click Clean & Minify. The tool parses it as XML, removes comments and metadata elements, strips editor-specific namespaced attributes, and collapses unnecessary whitespace — the result is valid, renders identically, and is meaningfully smaller.
Common use cases
- Preparing a design-tool-exported icon for inline use in a React component or HTML file
- Reducing SVG file size before embedding it as a data URI
- Cleaning up markup before committing an SVG asset to a codebase
Worked example
An Inkscape export with a comment, a <metadata> block containing RDF/Dublin Core data, inkscape:version and sodipodi:docname attributes on the root, and an inkscape:label on a <path> — as tested — has all of that removed, while the xmlns:inkscape="..." and similar namespace declarations on the root <svg> tag remain, now unused but harmless.
Common mistakes and edge cases
- It cleans, it does not redraw. Comments, editor data (Inkscape, Illustrator, Sketch) and extra whitespace are removed. The path numbers are not rounded and shapes are not merged, so the saving is smaller than a full optimiser gives on a drawing with long paths.
- Scripts and links stay. If an SVG from another source contains a script or an external link, it is still there after cleaning. Look at the result before you put an SVG you did not make on a page.
- Text with meaningful spaces. Runs of spaces are collapsed, which is right for most files but changes text that uses spacing on purpose. Compare the preview with the original.
- The outer element must be <svg>. A fragment, or a whole HTML page with an SVG inside, is refused with a message.