Live100% Client-Side

SVG Optimizer & Minifier

Sanitize and minify SVG markup while preserving responsive geometry and referenced definitions.

Clean and minify SVG markup locally with active-content sanitization, editor-metadata cleanup, optional numeric precision, and measured byte savings.

Workbench

Use SVG Optimizer & Minifier

Ctrl/⌘ + Enter to optimize
Quick samples:
Ready — 100% Client-Side
Removes XML <!-- comments -->
Removes <metadata>, Inkscape, Sodipodi, Illustrator tags
Collapses redundant indentation between tags
2 dec
Optional rounding (defaults off for maximum fidelity)
Source

SVG Code or File

1.1 KB
Drop an .svg file here, or
Optimized

Sanitized Result

942 B18.9% reduction
Isolated Vector PreviewRendered safely via isolated Object URL
Sanitized SVG Preview
Sanitization & Cleanup Report:
Comments removed: 4Metadata stripped: 0Scripts removed: 0Event handlers removed: 0Unsafe URLs removed: 0
What it does

Built for the task, not the page view

  • Remove comments, editor metadata, script elements, and event-handler attributes
  • Preserve viewBox plus referenced defs, gradients, clipPaths, IDs, and classes by default
  • Optional numeric precision rounding with measured before/after byte savings
  • Sanitized visual preview rendered without injecting raw SVG markup into the page
  • Copy and local .svg download with object-URL cleanup
Inputs & outputs
Accepts
SVG CodeSVG File
Produces
Optimized SVGSanitized Markup
Reference

Use it correctly

ViewBox Preservation & Responsive Scaling

The viewBox attribute defines the coordinate space and aspect ratio of your vector illustration. Removing viewBox breaks responsive CSS scaling (such as width: 100% or flexbox layouts), causing icons to crop or render at unexpected dimensions. EveryTools strictly preserves viewBox by default so your vectors remain responsive on any device or viewport.

Defs & Gradient Reference Safety

Vector graphics frequently declare linear gradients, radial gradients, clipping paths, masks, patterns, and markers inside <defs> blocks. These elements are referenced across your artwork via url(#id) attributes. EveryTools preserves referenced definitions, IDs, and class names by default, preventing graphics from rendering as unstyled black silhouettes.

Client-Side Active Content & SMIL Sanitization

SVG files are XML documents capable of executing arbitrary JavaScript and mutating DOM properties via embedded <script> tags, inline on* event handlers (like onclick or onload), HTML-embedding <foreignObject> blocks, dynamic SMIL animation elements (<animate>, <set>, <animateMotion>, <animateTransform>, <discard>), and external url(...) references. Our engine inspects and strips all active executable content and SMIL mutation elements before rendering or downloading, ensuring sanitized attributes cannot be altered post-render. Note that interactive or SMIL-animated SVGs will intentionally change after sanitization.

Coordinate Precision & Fidelity Tradeoffs

Path coordinates (d attribute) often contain up to 6 or 8 decimal places exported by design software. While rounding decimals saves bytes, aggressive rounding can distort subtle curves or collapse close anchor points. EveryTools prioritizes fidelity by leaving coordinates unrounded by default, while offering an optional deterministic precision toggle that preserves arc flags and scientific exponents.

Why Fixed Savings Percentages Are Not Promised

File size savings depend entirely on source markup and options; the tool reports measured actual bytes and percentages for the current SVG. Unoptimized exports loaded with metadata, comments, and redundant coordinate decimals may shrink significantly, while clean vectors or pre-minified assets may yield modest reductions. In cases where source markup is already minimal or formatting requires XML namespace declarations, file size may remain flat or increase slightly. EveryTools measures and reports exact byte changes rather than promising arbitrary fixed percentage ranges.

100% In-Browser Privacy Guarantee

All XML parsing, DOM sanitization, and serialization occur purely within your browser memory on your device. Vector artwork, proprietary brand logos, and source code are never uploaded to any remote server or EveryTools API. Analytics records only fixed UI action identifiers, never your SVG markup, coordinates, or file names.

W3C Scalable Vector Graphics Specification

SVG is an XML-based vector image format defined by the W3C. Vector nodes such as <path>,<rect>, <circle>, and <polygon> define shapes mathematically. Because SVG files are text-based markup, design tools routinely inject non-rendering editor metadata, XML namespace definitions, XML declarations, and design history layers that unnecessarily increase asset weight when deployed to production web applications.

XSS Sanitization & Active Content Removal

Unlike raster formats (JPEG, PNG, WebP), SVG files can execute arbitrary scripts when embedded inline or rendered in untrusted environments. EveryTools strips all <script> tags, <foreignObject> blocks,on* event-handler attributes, and javascript: URLs. If you allow raster data URIs, they are strictly restricted to PNG, JPEG, WebP, and GIF images; nested SVG data URIs are stripped.

Deterministic Coordinate Rounding Formula

When optional numeric precision rounding is enabled, coordinates are computed using Math.round(val * 10^precision) / 10^precision. Crucially, our tokenizer distinguishes coordinate values from elliptical arc flags (large-arc-flag and sweep-flag), which must remain strictly 0 or 1 to prevent corrupted geometry. Exponents like 1.2e-4 and transform functions are parsed deterministically without string truncation.

In-Browser DOMParser & XML Processing

This utility executes entirely client-side using standard browser DOMParser and XMLSerializer interfaces. Your graphics, proprietary logo geometry, and confidential illustrations remain strictly inside your browser tab memory. Network requests triggered by the platform never serialize or transfer your vector markup.

Frequently Asked Questions

Why did my SVG break when its viewBox was removed?

The viewBox attribute establishes the virtual canvas coordinate space. Without it, modern browsers cannot calculate aspect ratios for responsive scaling. If you set width: 100% on an SVG without a viewBox, the browser resizes the container box while clipping or overflowing the fixed pixel coordinates. EveryTools preserves the viewBox by default to guarantee responsive scaling.

What is the optimal coordinate decimal precision for web icons?

For standard 24px to 48px UI icons, 2 decimal places provides sub-pixel accuracy below 0.01px, which is visually indistinguishable from raw floating-point numbers on high-density Retina and OLED displays while trimming redundant fractional digits. File size savings depend on source markup and options; the tool reports measured actual bytes and percentages for the current SVG. For large illustrations or intricate vector artwork with extreme zoom requirements, leaving precision disabled (the default) ensures zero loss of geometric fidelity.

Will sanitization alter my interactive animated SVGs?

Yes, intentionally. If your SVG relies on embedded JavaScript (<script>), inline event handlers (onclick), or dynamic SMIL mutation elements (<animate>, <set>, <animateMotion>,<animateTransform>, <discard>), our security sanitizer conservatively removes them. SMIL and script elements can alter sanitized attributes after initial rendering, creating security risks. Interactive and animated SVGs can intentionally change after sanitization to ensure static security invariants. Pure CSS transitions and CSS keyframe animations (without external network imports) remain fully operational.