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

@svg.dog/svgdog

v1.0.0

Published

Official Node.js client for the svg.dog SVG optimization API

Readme

svgdog

The fastest way to optimize SVGs via API. Hosted SVG optimization powered by svg.dog — no SVGO config, no maintenance, always up to date.

npm install @svg.dog/svgdog
import { optimize } from '@svg.dog/svgdog';
import fs from 'node:fs';

const result = await optimize(fs.readFileSync('icon.svg'), { apiKey: 'YOUR_KEY' });
fs.writeFileSync('icon.min.svg', result.svg);
// → Saved 74.3%

Get a free API key at svg.dog →


Why use this instead of running SVGO locally?

| | svgdog | SVGO locally | |---|---|---| | Setup | npm install @svg.dog/svgdog | Install + configure | | Always latest SVGO | Yes | Manual updates | | Works in any language | Yes (REST API) | Node.js only | | Usage tracking | Yes | No | | Budget cap | Yes | No | | CI/CD friendly | Yes | Yes |


Installation

npm install @svg.dog/svgdog
# or
yarn add @svg.dog/svgdog
# or
pnpm add @svg.dog/svgdog

Requires Node.js 18+ (uses native fetch). Zero runtime dependencies.


Quick start

1. Get an API key

Sign up for free at svg.dog — 500 optimizations per month included, no credit card required.

2. Optimize a file

import { optimize } from '@svg.dog/svgdog';
import fs from 'node:fs';

const result = await optimize(fs.readFileSync('logo.svg'), {
  apiKey: process.env.SVGDOG_API_KEY!,
});

console.log(`Original:  ${result.originalSize} bytes`);
console.log(`Optimized: ${result.optimizedSize} bytes`);
console.log(`Saved:     ${result.savingsPercent.toFixed(1)}%`);

fs.writeFileSync('logo.min.svg', result.svg);

3. Use in a CI pipeline

# .github/workflows/optimize-svgs.yml
- name: Optimize SVGs
  run: |
    node -e "
    const { optimizeBatch } = require('@svg.dog/svgdog');
    const fs = require('fs');
    const glob = require('glob');

    const files = glob.sync('src/**/*.svg').map(p => ({
      name: p,
      data: fs.readFileSync(p),
    }));

    optimizeBatch(files, { apiKey: process.env.SVGDOG_API_KEY })
      .then(results => results.forEach(r => {
        if (r.success) fs.writeFileSync(r.filename, r.optimized);
      }));
    "
  env:
    SVGDOG_API_KEY: ${{ secrets.SVGDOG_API_KEY }}

API Reference

optimize(file, options)

Optimize a single SVG.

import { optimize } from '@svg.dog/svgdog';

const result = await optimize(buffer, { apiKey: 'YOUR_KEY' });

Parameters

  • fileBuffer | string — SVG content
  • options.apiKeystring — Your svg.dog API key

Returns Promise<OptimizeResult>

{
  svg: string;           // Optimized SVG as string
  originalSize: number;  // Bytes before
  optimizedSize: number; // Bytes after
  savingsPercent: number;// 0–100
  cached: boolean;
}

optimizeUrl(url, options)

Fetch and optimize an SVG from a public URL.

import { optimizeUrl } from '@svg.dog/svgdog';

const result = await optimizeUrl('https://example.com/logo.svg', { apiKey: 'YOUR_KEY' });

optimizeBatch(files, options)

Optimize multiple SVGs in one request. Free plan: up to 10 files. Pro: up to 50.

import { optimizeBatch } from '@svg.dog/svgdog';
import fs from 'node:fs';

const files = ['icon.svg', 'logo.svg'].map(name => ({
  name,
  data: fs.readFileSync(name),
}));

const results = await optimizeBatch(files, { apiKey: 'YOUR_KEY' });

results.forEach(r => {
  if (r.success) {
    fs.writeFileSync(r.filename, r.optimized!);
    console.log(`${r.filename}: saved ${r.savingsPercent?.toFixed(1)}%`);
  } else {
    console.error(`${r.filename}: ${r.error}`);
  }
});

getUsage(options)

Get your current monthly usage.

import { getUsage } from '@svg.dog/svgdog';

const stats = await getUsage({ apiKey: 'YOUR_KEY' });
console.log(`${stats.optimizations.total} optimizations used this month`);

SvgDog class

For repeated calls with the same key:

import { SvgDog } from '@svg.dog/svgdog';

const client = new SvgDog(process.env.SVGDOG_API_KEY!);

const result = await client.optimize(svgBuffer);
const stats  = await client.getUsage();

Error handling

All functions throw a standard Error with an additional status field for the HTTP status code:

try {
  const result = await optimize(buffer, { apiKey: 'YOUR_KEY' });
} catch (err: any) {
  if (err.status === 429) {
    console.error('Rate limit reached — upgrade at https://svg.dog/#pricing');
  } else {
    console.error(err.message);
  }
}

Pricing

| Plan | Price | Quota | |---|---|---| | Free | €0 | 500 optimizations/month | | Pay-per-Use | €0.005/optimization | Unlimited (first 500 free) | | Volume | €0.001/optimization | After 10,000/month |

View full pricing at svg.dog →


License

MIT — svg.dog is operated by Fasterminds GmbH