svgoo is a cross-platform SVG optimization tool that embeds the popular svgo JavaScript optimizer in a single Rust binary. No Node.js required!
# Install from source (releases coming soon)
git clone https://github.com/twardoch/svgoo.git
cd svgoo
npm run build && cargo build --release
# Optimize a single SVG file
./target/release/svgoo input.svg -o output.svg
# Process multiple files
./target/release/svgoo *.svg
# Use with pipes
cat input.svg | ./target/release/svgoo > output.svgDownload the latest release for your platform:
macOS (Intel):
curl -L https://github.com/twardoch/svgoo/releases/download/v1.2.0/svgoo-v1.2.0-macos-x86_64 -o svgoo
chmod +x svgoo
./svgoo --versionComing Soon:
- macOS (Apple Silicon)
- Linux (x86_64)
- Windows (x86_64)
Prerequisites:
git clone https://github.com/twardoch/svgoo.git
cd svgoo
npm install
npm run build
cargo build --releaseThe binary will be available at ./target/release/svgoo.
svgoo [OPTIONS] [INPUT_FILES...]| Option | Short | Description | Example |
|---|---|---|---|
--output |
-o |
Output file (use - for stdout) |
svgoo input.svg -o output.svg |
--help |
-h |
Show help information | svgoo --help |
--version |
-v |
Show version information | svgoo --version |
--quiet |
-q |
Suppress non-error output | svgoo --quiet input.svg |
--pretty |
Format output with indentation | svgoo --pretty input.svg |
|
--config |
-c |
Load configuration from file | svgoo --config svgo.config.json input.svg |
# Basic optimization
svgoo input.svg -o output.svg
# With pretty formatting
svgoo --pretty input.svg -o output.svg
# To stdout
svgoo input.svg# Process multiple files (creates .min.svg versions)
svgoo file1.svg file2.svg file3.svg
# Process all SVG files in directory
svgoo *.svg
# With custom output directory (via shell)
for file in *.svg; do
svgoo "$file" -o "optimized_${file}"
done# Standard Unix pipe
cat input.svg | svgoo > output.svg
# With other tools
curl -s https://example.com/icon.svg | svgoo | gzip > icon.svg.gz
# Process from web
wget -qO- https://example.com/icon.svg | svgoo -o icon.svg# Use custom configuration (coming in v2.0)
svgoo --config my-svgo.config.json input.svg- ✅ Single Binary: No Node.js or dependencies required
- ✅ Cross-Platform: Works on macOS, Linux, and Windows
- ✅ Fast: Basic SVG optimizations in ~100ms
- ✅ Compatible: Produces similar output to svgo
- ✅ Thoroughly Tested: 89 tests across all components and platforms
- ✅ Multiple Files: Process multiple SVG files at once
- Remove comments and metadata
- Remove unnecessary whitespace
- Clean up attributes
- Normalize formatting
- Remove empty elements (basic)
- 🔄 Full svgo plugin system compatibility
- 🔄 Custom configuration files
- 🔄 Performance optimizations
- 🔄 Python and C++ bindings
- 🔄 Advanced CLI features
| Tool | Time (100 files) | Binary Size | Dependencies | Test Coverage |
|---|---|---|---|---|
| svgoo | ~10s | <15MB | None | 89 tests |
| svgo | ~3s | N/A | Node.js + npm | Varies |
| oswg | ~2s | 50MB | None | Unknown |
Note: svgoo prioritizes convenience and portability over raw speed.
svgoo is designed as a drop-in replacement for basic svgo usage:
# Instead of this (svgo)
npx svgo input.svg -o output.svg
# Use this (svgoo)
svgoo input.svg -o output.svg✅ What works the same:
- Basic CLI interface (
input.svg -o output.svg) - Standard optimizations (comments, whitespace, etc.)
- File input/output handling
- Error handling and exit codes
- No plugin configuration yet (uses sensible defaults)
- Performance ~3-5x slower than native svgo
- Limited to built-in optimizations
❌ Not supported yet:
- Custom plugin loading
- Advanced configuration options
- Some edge-case optimizations
# Make sure the binary is in your PATH or use full path
./target/release/svgoo input.svg
# Or copy to a directory in PATH
cp target/release/svgoo /usr/local/bin/# Ensure JavaScript bundle is built first
npm run build
# Clean and rebuild
cargo clean && cargo build --release
# Check Rust version
rustc --version # Should be 1.70+# Rebuild the JavaScript bundle
npm install
npm run build
# Check bundle was created
ls -la js-dist/svgoo-embedded.js- svgoo currently applies basic optimizations only
- For advanced optimizations, use native svgo until v2.0
- File an issue if output differs significantly from expected
- Check existing issues: GitHub Issues
- Create new issue: Include input SVG, command used, and expected vs actual output
- Discussions: For questions and feature requests
If svgoo is too slow for your use case:
- Use native svgo for large-scale processing
- Process files in parallel:
ls *.svg | xargs -P 4 -I {} svgoo {} - Consider using release builds:
cargo build --release
svgoo embeds the svgo JavaScript optimizer using QuickJS runtime:
Input SVG → Rust CLI → QuickJS Runtime → svgo.js → Optimized SVG
This approach provides:
- Single binary: No external dependencies
- Compatibility: Same optimization logic as svgo
- Reliability: Rust's memory safety + JavaScript's flexibility
We welcome contributions! See CONTRIBUTING.md for guidelines.
git clone https://github.com/twardoch/svgoo.git
cd svgoo
npm install && npm run build
cargo build
cargo testsvgoo/
├── src/ # Rust source code
│ ├── main.rs # CLI entry point
│ ├── lib.rs # Library interface
│ └── ... # Core modules
├── js-src/ # JavaScript source
├── js-dist/ # Built JavaScript bundle
├── tests/ # Integration tests
└── docs/ # Documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- svgo - The excellent SVG optimizer this tool embeds
- QuickJS - Lightweight JavaScript engine
- rquickjs - Rust bindings for QuickJS
- Basic SVG optimization
- File I/O support
- Multiple file processing
- Cross-platform builds
- Comprehensive documentation
- Thorough testing (89 tests)
- Cross-platform verification
- Production-ready error handling
- Full svgo plugin system
- Custom configuration files
- Performance optimizations
- Python/C++ bindings
- GUI application
- Watch mode for development
- Advanced optimization algorithms
- Cloud integration
Made with ❤️ by the svgoo team