Subscribe Free

Join 2670+ others. No spamming.
I promise!

We are currently under high development. Follow us at github.

Looking for Python Tutorials?
Check these awesome tutorials



RazrFalcon / svgcleaner


svgcleaner could help you to clean up your SVG files from the unnecessary data.



svgcleaner could help you to clean up your SVG files from the unnecessary data.

Build Status

Table of Contents


The main purpose of the svgcleaner is to losslessly reduce size of an SVG image, created in a vector editing application, before publishing.

Usually, more than half of an SVG image data is useless for rendering:

  • Temporary data used by the vector editing application.
  • Non-optimal SVG structure representation.
  • Unused and invisible graphical elements.
  • ...


  1. Correctness. svgcleaner should not break an SVG file.
  2. Cleaning ratio. More is better.
  3. Performance. An average SVG file processing time should be closer to ~1ms on a modern PC.


Despite obvious advantages of the svgcleaner, like correctness, cleaning ratio and performance, which is shown below, there are some more nuances:

  1. svgcleaner cleans only one SVG file. It doesn't process SVGZ files. It doesn't process directories. It doesn't do anything else. Just one task*.
  2. svgcleaner is strictly lossless. There are no destructing cleaning options.
  3. svgcleaner is portable. You can build it into a single executable without any external dependency.

* You can get all of this features using GUI.


See 'Testing notes' for details.

All stats was collected using the latest release version.


Less is better.

Alt text

* Most of the errors are due to incorrect font-face processing. Not font-based errors:

  • svgo: 100
  • scour: 78

Alt text

* Errors produced by the numeric rounding are ignored.

Cleaning ratio

More is better.

Alt text

* Note that svgo and scour breaks most of the files.

Alt text

Cleaning time

Less is better.

Alt text

Alt text


Collection Size Before (MiB) Size After (MiB) Ratio (%)
Breeze icons theme 21.72 11.09 48.91
Ardis icons theme 11.82 5.23 55.74
Humanity icons theme 8.56 3.08 64.01
Open Icon Library 207.45 69.44 66.53
Elementary icons theme 17.72 7.09 59.95
Adwaita icons theme 2.21 0.37 83.08
Faience icon theme 22.35 11.14 50.16
GCP Icons 0.344 0.082 75.9

You can find more tests, with detailed explanations of errors, here.



svgcleaner shouldn't change your file unless you say it to, but there are still things that can't be preserved. So even if you disable all cleaning options there are still things that will be changed:

  • Original indent is not preserved.
  • All colors will be formatted as #RRGGBB and #RGB.
  • DOCTYPE, CDATA will be processed and removed.
  • CSS support is minimal.
  • CSS from the style element will be extracted and processes. The style element will be removed.
  • The style attribute will be split into attributes.
  • The class attribute will be processed and removed.
  • Paths and transformations will be reformatted.
  • currentColor and inherit attributes values will be resolved.
  • Referenced elements will be moved to the defs element.
  • IRI and FuncIRI attributes that reference non-existing objects will be removed.
  • If the offset attribute value of the stop element represented as percent - it will be converted into a number.



svgcleaner in.svg out.svg

Change default options:

svgcleaner in.svg out.svg --indent=2 --paths-coordinates-precision=5 --join-arcto-flags=true

Use --help for a list of the cleaning options and the doc for more details.


You can get a GUI here.


You can get prebuild packages here.


You need the latest stable Rust compiler.

cargo build --release

If you're a Rust programmer, you can install svgcleaner using:

cargo install svgcleaner

Contributing and Issues

See for details.



svgcleaner is licensed under the GPL-2.0.