Documentation
CLI Reference
SVGM ships as a single binary. By default, it optimizes SVG files in place. When piped, output goes to stdout automatically.
svgm <input> [OPTIONS]Options
| Flag | Description |
|---|---|
| <input> | One or more SVG file paths. Supports globs. |
| -o, --output <path> | Write optimized output to a different file. Errors if multiple inputs are given. |
| --stdout | Print optimized SVG to stdout instead of overwriting the input file. |
| --preset <safe|balanced|aggressive> | Safety preset. safe runs 17 passes (removal, normalization, output). balanced runs all 24 (default). aggressive uses all 24 with lower precision (2). |
| --precision <N> | Decimal precision for numeric rounding. Overrides the preset default. Default: 3. |
| --config <path> | Path to a svgm.config.toml configuration file. |
| --no-config | Skip automatic config file discovery. |
| --dry-run | Preview size reduction without writing any files. |
| -q, --quiet | Suppress all output except errors. |
Examples
Optimize in place (overwrites the file)
svgm icon.svgWrite to a different file
svgm icon.svg -o icon.min.svgPrint to stdout instead of overwriting
svgm icon.svg --stdoutPreview size reduction without writing
svgm icon.svg --dry-runOptimize multiple files in place
svgm icons/*.svgUse only safe passes (removal, normalization, output)
svgm icon.svg --preset safeMaximum compression with lower precision
svgm icon.svg --preset aggressiveSuppress all output except errors
svgm icon.svg --quietOutput format
Unless --quiet is set, SVGM prints a summary for each file:
icon.svg
13.5 KiB -> 6.6 KiB (51.1% smaller) 0ms 3 passesShows the filename, original and optimized sizes, percentage reduction, elapsed time, and the number of convergence iterations.
Piping
When stdout is not a terminal (e.g. piped to another command), SVGM automatically outputs to stdout instead of overwriting the input file.
svgm icon.svg | gzip > icon.svgz