Optimize SVG
Try it interactively →POST /api/svg-optimizeOptimise SVG output: strip editor metadata, comments, redundant attributes, and unused `<defs>`. Often shaves 30–60% of the file size with no visual change.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| svg* | string | — | SVG source as text. |
| pretty | boolean | false | Pretty-print the output instead of minifying. |
| removeViewBox | boolean | false | Remove the `viewBox` attribute (breaks responsive SVGs — only enable if you have explicit width/height). |
| floatPrecision | number (1…8) | 3 | Decimal precision for numeric values. |
Response
Modes: json, text. Cache: yes (24h TTL).
Code samples
Built from the icon example.
curl -X POST https://api.xtract.bot/api/svg-optimize \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
-H "X-Api-Key: $XTRACT_API_KEY" \
-d '{
"svg": "<?xml version=\"1.0\"?>\n<!-- comment -->\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" version=\"1.1\" fill=\"none\" stroke=\"currentColor\"><path d=\"M12.000 2.000 L18.000 8.000 L12.000 14.000 L6.000 8.000 Z\"/></svg>",
"pretty": false,
"floatPrecision": 2
}'