npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

svgtidy

v0.1.4

Published

High-performance SVG optimizer written in Rust

Downloads

428

Readme

Logo

CI License Crates.io Version NPM Version

svgtidy is a high-performance SVG optimizer written in Rust.

It removes redundant information from SVG files (like comments, metadata, and hidden elements) and creates a minimized, cleaner version without affecting rendering.

Compared to SVGO, svgtidy is fast—up to 100x faster for single icons and 50x faster for complex files.


⚡ Features

  • Blazing Fast: Built with Rust, xmlparser and rayon.
  • Batch Processing: Parallel directory scanning and optimization.
  • AST-based: Robust DOM-like mutations.
  • Configurable: Toggle plugins, set precision, and precision formatting.
  • Cross-Platform: Runs on CLI, Node.js, and in the browser (WASM).

🚀 Installation & Usage

📦 Node.js / Web (WASM)

Use svgtidy directly in your JavaScript/TypeScript projects.

npm install svgtidy

Usage:

import { optimize } from 'svgtidy';

const svg = '<svg>...</svg>';
const optimized = optimize(svg);
console.log(optimized);

🦀 CLI (Command Line)

Install the binary tool using Rust's cargo:

# Install from crates.io (Recommended)
cargo install svgtidy

# Or build from source
git clone https://github.com/honkinglin/svgtidy.git
cd svgtidy
cargo install --path .

Usage:

# Optimize a single file
svgtidy input.svg -o output.svg

# Optimize a directory (recursive)
svgtidy icons/ -o dist/

# Set precision and disable specific plugins
svgtidy input.svg -o output.svg -p 5 --disable removeTitle

⚡ Vite

Install the dedicated Vite plugin:

npm install vite-plugin-svgtidy

Usage (vite.config.js):

import svgtidy from 'vite-plugin-svgtidy';

export default {
  plugins: [svgtidy()]
}

📦 Webpack

Install the Webpack loader:

npm install svgtidy-loader

Usage (webpack.config.js):

module.exports = {
  module: {
    rules: [
      {
        test: /\.svg$/,
        use: [
          { loader: 'svgtidy-loader' }
        ]
      }
    ]
  }
}

⚙️ Configuration (CLI)

Usage: svgtidy [OPTIONS] <INPUT>

Arguments:
  <INPUT>  Input file or directory

Options:
  -o, --output <OUTPUT>    Output file or directory
  -p, --precision <PRECISION>  Set numeric precision [default: 3]
      --enable <ENABLE>    Enable specific plugins (comma-separated)
      --disable <DISABLE>  Disable specific plugins (comma-separated)
      --pretty             Pretty print output
  -h, --help               Print help

🔌 Plugins

svgtidy enables these plugins by default to ensure maximum reduction:

| Plugin Name | Description | | :--- | :--- | | removeDoctype | Removes <!DOCTYPE> declaration. | | removeXMLProcInst | Removes <?xml ... ?> instructions. | | removeComments | Removes comments. | | removeMetadata | Removes <metadata> elements. | | removeTitle | Removes <title> elements. | | removeDesc | Removes <desc> elements. | | removeEditorsNSData| Removes editor namespaced attributes (Inkscape, etc.). | | cleanupAttrs | Trims attribute whitespace. | | mergePaths | Merges adjacent paths with same attributes. | | convertShapeToPath | Converts basic shapes (rect, circle) to path. | | convertPathData | Optimizes path commands (relative, precision). | | convertTransform | Collapses multiple transforms into one. | | removeHiddenElems | Removes hidden elements (display="none"). | | removeEmptyText | Removes empty text nodes. | | convertColors | Converts colors (rgb to hex, etc.). | | collapseGroups | Removes redundant <g> tags. | | moveGroupAttrsToElems| Moves attributes from groups to elements. | | moveElemsAttrsToGroup| Moves common attributes from elements to groups. |

(And more...)

📊 Benchmarks

| Scenario | Input Size | svgtidy Time | vs SVGO (Node) | | :--- | :--- | :--- | :--- | | Simple Icon | ~0.5 KB | ~16 µs | ~100x Faster | | Complex SVG | ~30 KB | ~1 ms | ~50x Faster |

� Development

Build WASM locally

To build the WASM package for web usage (NPM):

wasm-pack build --target bundler --out-dir npm/svgtidy-wasm

Running Tests

  • Rust: cargo test
  • JS/WASM: cd npm && npm run test:suite

🤝 Contributing

Contributions are welcome!

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a Pull Request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.