Skip to content

SVG Optimizer

Clean and shrink SVG files in your browser. Upload or paste SVG code, remove scripts, event handlers, embedded HTML and external URLs, strip comments, metadata, editor data and empty groups, and compare before/after previews, sizes and source.

Image Runs client-side Free to use
Jump to the tool
Share: X WhatsApp
Loading SVG Optimizer…

About the SVG Optimizer

SVG Optimizer cleans up an SVG file and makes it smaller without sending it anywhere. Upload a .svg file or paste SVG code, and the tool first sanitises it: scripts, event-handler attributes such as onclick and onload, embedded HTML inside foreignObject, external URLs and references, links, and elements outside a safe SVG allowlist are removed, while same-file references and embedded raster images are kept. It then applies conservative optimisations — removing comments, metadata, editor-specific data from apps like Inkscape and Illustrator, empty groups, unused IDs and extra whitespace — with optional title/description removal and number rounding.

You see the original size, the optimised size, the bytes saved and the percentage saved, a list of what was removed, before and after previews and both sources side by side. Previews are drawn as images, so nothing inside the SVG can run. The optimisations aim to keep the appearance, but this is not a guaranteed lossless process: rounding numbers, removing IDs that outside CSS relies on, or browser differences can change how a file looks, so compare the previews before you use the result.

How to use

  1. Choose or drop an .svg file, or paste SVG code into the box.
  2. Pick the optimisation options — keep the defaults for the safest result.
  3. Click Sanitise & optimise (files are processed automatically).
  4. Check the sizes, the removal list and the before/after previews.
  5. Copy the optimised code or download it as an .svg file.

Key features

  • Upload a file or paste code, up to 5 MB.
  • Security clean-up of scripts, event handlers, embedded HTML, external URLs and unsafe elements.
  • Removes comments, metadata, editor data, empty groups, unused IDs and whitespace.
  • Optional removal of title/desc and optional number rounding (1–3 decimals).
  • Original, optimised and saved bytes plus percentage saved.
  • Safe image previews and before/after source, with copy, download and Reset.

Best practices

  • Compare the before and after previews before replacing the original.
  • Leave “Remove unused IDs” off if a web page’s CSS or JavaScript targets IDs in the SVG.
  • Keep title and desc for icons and graphics that need an accessible name.
  • Use rounding only after checking that fine detail still looks right.
  • Keep a copy of the original file in case you need to edit it later.

Benefits

  • Smaller SVGs for faster web pages.
  • Safer SVGs with active and external content removed.
  • Clear reporting of exactly what changed.
  • No uploads, accounts or installs.

Frequently asked questions

Is the optimisation lossless?

Not guaranteed. The default options aim to keep the appearance, but rounding numbers, removing IDs referenced from outside the file and other clean-up can change the rendering. Always compare the before and after previews.

What does the security clean-up remove?

Script elements, on… event-handler attributes, foreignObject and other embedded HTML, links, javascript: and other dangerous values, external URLs in href and url(), @import rules and elements outside a safe SVG allowlist. References inside the same file (#id) and embedded raster images (data:image) are kept.

Why is my optimised file larger or barely smaller?

Files that are already minified have little left to remove, and the serialiser can add a namespace attribute that was missing. The tool reports this honestly instead of claiming a saving.

Why does the preview look different from my design app?

Browsers do not support every SVG feature in the same way, and fonts or images linked from outside the file are not loaded for safety. Text uses fonts available on your device.

Can it open malformed SVG?

No. If the code is not well-formed XML, or it uses DOCTYPE entities, the tool shows an error instead of guessing. Fix the reported problem in the source and try again.

Does it convert text to paths or merge shapes?

No. It does not rewrite shapes or paths beyond optional number rounding and whitespace clean-up, which keeps the result predictable.

Is my SVG uploaded anywhere?

No. The SVG is read, sanitised and processed by JavaScript in your browser tab. Nothing is sent to a server, and the SVG code and results are not saved in browser storage.