SVGO CLI
Command-line interface for SVGO - the SVG optimizer.
Installation
dart pub global activate svgo_cli
Usage
# Optimize a single file (overwrites input)
svgo input.svg
# Optimize to output directory
svgo -o dist input.svg
# Optimize multiple files
svgo icon1.svg icon2.svg icon3.svg
# Optimize all SVGs in a directory (using glob pattern)
svgo "src/**/*.svg"
# Multipass optimization
svgo -m input.svg
# Custom precision (2 decimal places)
svgo -p 2 input.svg
# Quiet mode (no output messages)
svgo -q input.svg
# Show help
svgo --help
# Show version
svgo --version
Options
| Option | Short | Description |
|---|---|---|
--help |
-h |
Show help message |
--version |
-v |
Show version information |
--output <DIR> |
-o |
Output directory (default: overwrite input) |
--quiet |
-q |
Suppress output messages |
--recursive |
-r |
Process directories recursively |
--precision <NUM> |
-p |
Float precision (default: 3) |
--multipass |
-m |
Run optimizations multiple times |
Examples
Optimize a single file
svgo logo.svg
Output:
logo.svg → logo.svg (1234 → 789 bytes, 36.1% saved)
Processed 1 file(s), saved 445 bytes total.
Batch processing
svgo -o optimized "assets/**/*.svg"
CI/CD Usage
# Quiet mode for scripts
svgo -q -o dist *.svg
Configuration
The CLI uses the default preset (preset-default) with safe optimizations. Future versions will support configuration files for custom plugin settings.
Exit Codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Error (file not found, parse error, etc.) |
License
MIT License - Copyright (c) 2025 iota9star
Libraries
- svgo_cli
- SVGO CLI - Command-line interface for SVG optimization.