تخطي إلى المحتوى
POST AI agent ready /v1/svg/optimize

SVG Optimize API - Strip Editor Metadata and Whitespace

Removes XML declarations, doctypes, comments, <title>/<desc>/<metadata> blocks, empty <g>/<defs>, Inkscape and Sodipodi editor attributes and namespaces, unused xmlns:xlink, autogenerated IDs (layer1, g1234), and collapses whitespace. Accepts SVGs up to 500 KB and returns optimized output with byte counts and savings percent.

Parameters

stringrequired

SVG source to optimize.

Code examples

curl -X POST https://api.botoi.com/v1/svg/optimize \
  -H "Content-Type: application/json" \
  -d '{"svg":"<?xml version=\"1.0\"?>\n<!-- Generated by Inkscape -->\n<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" viewBox=\"0 0 24 24\">\n  <title>Circle</title>\n  <g id=\"layer1\">\n    <circle cx=\"12\" cy=\"12\" r=\"10\"/>\n  </g>\n</svg>"}'

When to use this API

Strip designer tool metadata before shipping icons

Icons exported from Figma, Illustrator, or Inkscape carry editor metadata (layer names, app namespaces). Optimize before bundling into your icon pack to cut payload weight.

Sanitize user-uploaded SVGs

Users pasting icons from the web often bring editor cruft. Optimize server-side before storage; saves DB space and removes fingerprinting via editor signatures.

Build-step SVG compression

Add as a pre-commit or CI step that optimizes every SVG in your static directory. Keeps the repo lean and page loads fast.

Frequently asked questions

Is this equivalent to SVGO?
Not as aggressive. SVGO offers dozens of plugin-based passes (path rewriting, geometry merging, attribute collapsing). This endpoint focuses on the safe, high-ROI wins: metadata stripping and whitespace. For max compression, run SVGO locally.
Does it touch path data?
No. <path d="..."> data is preserved exactly. Only whitespace inside attribute values is collapsed.
What about CSS inside <style>?
CSS inside <style> blocks is preserved as-is. Run the CSS through /v1/minify/css separately if you want to minify it.
Are <title> and <desc> always removed?
Yes. These accessibility tags are often unused in programmatic icon sprites. If you need them for screen readers, don't run this endpoint on those SVGs or re-add the tags after optimization.
What's the size limit?
500 KB per input. For larger SVGs (complex illustrations, dense maps) run SVGO locally.

Get your API key

Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.