SVG Optimizer

Optimization Options

Reduce SVG file size by removing unnecessary metadata, comments, and optimizing code.

API Access

Use this tool programmatically via our REST API. Perfect for build pipelines, batch processing, and automated SVG optimization.

Endpoint

POST https://toolteeno.com/api/svg-optimizer

Request Body

{
  "svg": "string",              // Required: SVG content to optimize
  "options": {
    "removeComments": true,     // Remove XML comments
    "removeMetadata": true,     // Remove metadata, title, desc
    "removeHiddenElements": true, // Remove hidden elements
    "minifyColors": true,       // Minify color values
    "removeEmptyAttrs": true,   // Remove empty attributes
    "precision": 2              // Number precision (0-5)
  }
}

Example Response

{
  "success": true,
  "optimized": "<svg>...</svg>",
  "stats": {
    "originalSize": 1024,
    "optimizedSize": 512,
    "savings": 50,
    "originalSizeKB": "1.00",
    "optimizedSizeKB": "0.50"
  }
}

cURL Example

curl -X POST https://toolteeno.com/api/svg-optimizer \
  -H "Content-Type: application/json" \
  -d '{
    "svg": "<svg><circle cx=\"50\" cy=\"50\" r=\"40\"/></svg>",
    "options": {
      "removeComments": true,
      "minifyColors": true
    }
  }'

JavaScript/Fetch Example

const svgContent = '<svg>...</svg>';

const response = await fetch('https://toolteeno.com/api/svg-optimizer', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    svg: svgContent,
    options: {
      removeComments: true,
      removeMetadata: true,
      minifyColors: true,
      precision: 2
    }
  })
});

const data = await response.json();
console.log(`Saved ${data.stats.savings}%`);
console.log(data.optimized);

Python Example

import requests

with open('input.svg', 'r') as f:
    svg_content = f.read()

response = requests.post(
    'https://toolteeno.com/api/svg-optimizer',
    json={
        'svg': svg_content,
        'options': {
            'removeComments': True,
            'removeMetadata': True,
            'minifyColors': True,
            'precision': 2
        }
    }
)

result = response.json()
print(f"Saved {result['stats']['savings']}%")

with open('output.svg', 'w') as f:
    f.write(result['optimized'])

Optimization Benefits

  • Faster Load Times: Smaller files load faster
  • Reduced Bandwidth: Save on data transfer costs
  • Better Performance: Improved Lighthouse scores
  • Cleaner Code: Remove editor-specific metadata
  • SEO Benefits: Faster pages rank better
  • Typical Savings: 30-70% file size reduction

This API is completely free to use with no rate limits or authentication required!