Skip to main content

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 browser

Cleaned SVG

The cleaned SVG appears here.

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.

Frequently asked questions

What gets removed when I clean an SVG?
Comments, <metadata> elements (typically containing RDF/Dublin Core data no browser renders), and attributes in editor-specific namespaces like inkscape:*, sodipodi:*, and sketch:* — all of which are safe to remove since they have no visual effect and exist only for the original editing tool.
Will cleaning change how my SVG looks?
No — everything removed is invisible metadata or editor bookkeeping that browsers don't render. The visible shapes, paths, and styling are left untouched.
Is my SVG uploaded anywhere?
No — parsing and cleaning happen entirely in your browser using the native DOMParser and XMLSerializer APIs. Nothing you paste is sent to a server.
Can I use the output directly in React or HTML?
Yes — the cleaned output is standard SVG markup, safe to paste directly into an HTML file or as inline JSX in a React component.
Does cleaning remove the xmlns:inkscape and similar namespace declarations too?
No — in practice, only the namespaced attributes themselves (like inkscape:label) are removed. The xmlns:inkscape="..." declaration that introduced that prefix on the root <svg> tag stays, even once nothing in the document uses it anymore. It's harmless (unused namespace declarations don't affect rendering) but you may notice it if you're comparing markup closely.
Can SVG optimization change how an image renders?
Sometimes. Removing comments, editor data and extra whitespace does not change what you see. Cleaning that removes IDs, merges styles or shortens paths can break animations, CSS rules that point at an ID or a screen reader label. Compare the preview with the original and keep the original file.

Related tools

More Frontend & Design

View all Frontend & Design tools →