svgcleaner

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

Table of Contents

Purpose

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. - ...

Goals

  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.

Alternatives

There are only one real alternative to the svgcleaner - svgo.

Despite obvious advantages of the svgcleaner, like correctness, cleaning ratio and performance, which is shown bellow, 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 and never will be.
  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.

Charts

See 'Testing notes' for details.

Correctness

Less is better.

Alt text

* Yes, svgcleaner 0.6.2 is absolute garbage on this data set.

Alt text

Cleaning ratio

More is better.

Alt text

* And again, svgcleaner 0.6.2 is kinda superb, but since it breaks most of the files - it's pointless. Same goes for svgo.

Alt text

Cleaning time

Less is better.

Alt text

Alt text

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

Limitations

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:

Building

You need the latest stable Rust compiler.

bash cargo build --release

Usage

CLI

svgcleaner in.svg out.svg

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

GUI

You can get a GUI here.

Downloads

You can get prebuild packages here.

Contributing and Issues

See CONTRIBUTING.md for details.

FAQ

License

svgcleaner is licensed under the GPL-2.0.