webdev_svg_optimizer
Minify and optimize SVG markup by removing XML declarations, comments, DOCTYPE, empty elements, default attributes, redundant groups, and whitespace. Get optimized output, size savings, and a data-URL preview.
Instructions
SVG Optimizer and Minifier. Minify and optimize an SVG markup string by stripping the XML declaration, comments, DOCTYPE, empty elements, default attributes, redundant groups, and whitespace, plus shortening colors and rounding coordinate precision. Pass the raw SVG text in the svg field; the file is never uploaded. Use webdev_css_minifier or webdev_html_minifier for CSS/HTML, or webdev_data_uri_generator and webdev_base64_image_encoder to embed the result. Runs locally: read-only, non-destructive, contacts no external service, and is rate-limited (60 requests/minute for anonymous callers). Returns the optimized markup, before/after byte sizes, compression ratio, the list of optimizations applied, and a base64 data-URL preview.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| svg | Yes | Raw SVG markup to optimize. Must contain a valid svg root element or the request is rejected. | |
| options | No | Optional toggles; each optimization defaults to enabled unless explicitly set to false. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| optimizedSvg | No | The optimized SVG markup string. | |
| originalSize | No | Character length of the input SVG. | |
| optimizedSize | No | Character length of the optimized SVG. | |
| compressionRatio | No | Percent size reduction relative to the original. | |
| bytesSaved | No | Characters removed (original minus optimized). | |
| optimizationsApplied | No | Human-readable labels for each optimization performed. | |
| previewDataUrl | No | Base64 data URL of the optimized SVG for preview. |