xtract.bot
POST /api/svg-optimize

Optimise SVG output: strip editor metadata, comments, redundant attributes, and unused `<defs>`. Often shaves 30–60% of the file size with no visual change.

Minifies an SVG document. Removes: - Editor metadata (Inkscape / Illustrator / Sketch tags). - Comments. - Redundant attributes (defaults, no-ops). - Unused `<defs>` (filters / gradients / patterns that no visible element references). - Empty containers. Typically reduces file size 30–60% with no visual change.

Inputs

NameTypeDefaultDescription
svg*stringSVG source as text.
prettybooleanfalsePretty-print the output instead of minifying.
removeViewBoxbooleanfalseRemove the `viewBox` attribute (breaks responsive SVGs — only enable if you have explicit width/height).
floatPrecisionnumber (1…8)3Decimal 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
}'