Skip to content
ToolZone

SVG Optimizer

Strip unnecessary metadata, comments, and redundant path data from an SVG file, reducing its size without changing how it looks.

Runs in your browser. Nothing you enter or upload leaves your device.

Keyboard shortcuts

Run the main action
⌘ / Ctrl + Enter
Copy the result
⌘ / Ctrl + Shift + Enter
Download the result
⌘ / Ctrl + S
Paste a file or image into file tools
⌘ / Ctrl + V
Search all tools
⌘ / Ctrl + K
Show these shortcuts
?

You can also drop files anywhere on the page.

About the SVG Optimizer

The SVG Optimizer cleans up SVG markup by removing comments and collapsing unnecessary whitespace, then renders a preview so you can confirm the graphic still looks right. It is a quick tidy-up for icons and illustrations you plan to inline in HTML or ship on a website.

How it works

When you click Optimize SVG, the tool runs a series of text replacements: it deletes HTML-style comments, turns any run of whitespace into a single space, removes whitespace between > and <, after < and before >, removes spaces around = signs, and trims the ends. Attributes, paths and numbers are left exactly as they were.

That makes this a whitespace-and-comment minifier rather than a full optimizer like SVGO. It does not remove editor metadata elements, round path coordinates, merge shapes or drop unused definitions, so savings come mainly from formatting. The result is shown as code, rendered as an image, and offered as a downloadable file.

How to use

  1. 1

    Open your SVG in a text editor and paste the code into the input box.

  2. 2

    Click Optimize SVG.

  3. 3

    Check the preview to make sure the graphic looks unchanged.

  4. 4

    Copy the code from the output panel or click the download icon to save optimized.svg.

Worked examples

Exported icon with a comment

An icon exported from a design tool.

Input
<!-- Generator: Sketch --> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <circle cx="12" cy="12" r="10" fill="#4f46e5" /> </svg>
Result
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="#4f46e5" /></svg>

The comment, line breaks and indentation are removed: 145 characters become 114, a saving of 31 bytes (21%).

Limitations
It only removes comments and whitespace; metadata elements, hidden layers and excessive coordinate precision are kept. Spaces around = are removed everywhere, including inside text content and attribute values such as CSS in style attributes. There is no file picker; you need to paste SVG code, and the download may fail if the SVG contains non-Latin characters.
Assumptions
Input is a complete SVG document or fragment that you trust to preview in the page.
Privacy
The SVG is processed in your browser and is not uploaded or stored.

Frequently asked questions

Will optimizing change how my SVG looks?+

Normally not, because only comments and whitespace between tags and attributes are removed. Check the preview, especially for SVGs with <text> elements or inline CSS, where whitespace can matter.

Where does the extra data in an SVG usually come from?+

Design tools add generator comments, editor-specific metadata, IDs and indentation, and often write coordinates with many decimal places. This tool removes the comments and indentation; a full optimizer is needed for the rest.

How much smaller will my SVG get?+

For hand-formatted or pretty-printed files, typically 10 to 30 percent. Files where most of the size is path data will shrink less, because path coordinates are not changed.

Can I upload an SVG file?+

No, paste the code instead. Open the .svg file in any text editor to copy its contents.

Related tools