PixKit

Home / All Tools /Utility

SVG Optimizer

Strip comments and redundant attributes, merge adjacent paths, compress numeric precision and compare size.

✓ Local processing · No uploads · No signup

Drop an SVG file, or click to browse

Parsed locally; preview uses an <img> so embedded scripts never run

Original

—

Optimized

—

Optimized

Boolean path merging and CSS rewriting are not implemented yet to avoid changing rendering.

Real-world uses

  • A Figma export of icon.svg carries data-name, inkscape attributes and a metadata block. Enable metadata removal, set precision to 2 and turn on path merging; the size panel then reports bytes before and after plus the number of removed items.
  • Inlining an SVG into HTML: optimise first, then copy the code. With comments and inter-tag whitespace gone, editor namespaces no longer trip validators in the template, and the output still has a complete svg root element.

Limits: Numeric rounding is lossy: only numbers with decimals change, while integers, ids and colours are left alone, so precision 0 can shift fine paths slightly. Merging only joins adjacent paths whose attributes other than d match exactly. With metadata removal on, xlink-prefixed attributes are removed too, so legacy icons using use xlink:href should switch to href or turn the option off.

Related tools:Rasterise to PNG when you need a bitmapInline as Base64 instead

How it works

  1. Upload a .svg file; it is parsed with DOMParser and rejected if the root element is not svg
  2. Set numeric precision (0-4 decimals) and choose metadata removal and adjacent path merging
  3. Review UTF-8 bytes before and after, removed items and merged paths, then download or copy the code

FAQ

Will optimization change how the SVG renders?

Slightly, in some files. Removing comments, attributes and whitespace does not change rendering, but numeric rounding is approximate and merging concatenates two d values into one. There are no boolean path operations or CSS rewrites. Compare the preview before downloading and avoid jumping straight to precision 0.

Why are so few paths merged?

Only adjacent paths with identical fill/stroke/transform attributes are merged. Different attributes would break rendering, so the optimizer stays conservative.

Why did the file barely shrink?

A hand-written SVG with integer coordinates has little to remove: integers, ids and colours are never rounded. In that case the byte difference mostly comes from collapsing whitespace between tags.

Can merging paths change the fill result?

Merging requires an identical attribute signature for fill, stroke, transform and so on, but concatenating d can change how overlapping subpaths fill under a given fill-rule. For icons with holes or self-intersecting paths, turn merging off and keep only the cleanup.

Related tools