LinuxCommandLibrary

svgcleaner

Lossless SVG file optimizer

TLDR

Clean SVG

$ svgcleaner [input.svg] [output.svg]
copy
Maximum compression
$ svgcleaner --preset=maximum [input.svg] [output.svg]
copy
Preserve specific attributes
$ svgcleaner --keep-named-ids [input.svg] [output.svg]
copy
Indent output
$ svgcleaner --indent [2] [input.svg] [output.svg]
copy
Quiet mode
$ svgcleaner -q [input.svg] [output.svg]
copy

SYNOPSIS

svgcleaner [--preset preset] [options] input output

DESCRIPTION

svgcleaner performs lossless optimization of SVG files, reducing file size without altering their visual appearance. It removes unnecessary metadata, editor artifacts, unused definitions, and redundant attributes that bloat SVG files exported from graphic editors.
The tool simplifies path data, optimizes geometry, merges compatible elements, and removes empty groups and containers. Multiple optimization passes can be applied for maximum size reduction. Optimization presets allow choosing between conservative and aggressive cleaning levels.
Written in Rust for performance, svgcleaner is particularly effective at cleaning SVGs produced by editors like Inkscape, Adobe Illustrator, and Sketch, which often embed substantial editor-specific metadata and redundant styling information.

PARAMETERS

--preset NAME

Optimization preset.
--keep-named-ids
Preserve IDs.
--indent N
Indentation spaces.
-q
Quiet mode.
--multipass
Multiple optimization passes.

CAVEATS

May break complex SVGs. Test output. Rust written.

HISTORY

svgcleaner was created as a lossless SVG optimizer, reducing file size without affecting visual appearance.

SEE ALSO

svgo(1), inkscape(1), scour(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community