# SVG Path Optimizer

> Optimize and compress SVG code by removing unnecessary metadata, comments, and redundant attributes. Reduce file size instantly.

- Open the tool: https://overtooled.com/svg-optimizer
- Category: Developer
- Privacy: Runs entirely in your browser. Nothing is uploaded, no account is needed, and it works offline once loaded.
- Price: free, no sign-up
- Keywords: svg, optimize, compress, svgo, path, vector

## In short

Optimize and compress SVG code.

## Overview

Shrinks SVG markup with a set of regex-based cleanup passes and shows the byte savings. Useful for stripping editor cruft (Inkscape, Sodipodi, Sketch metadata), comments and default attributes before embedding an icon or illustration. It is not SVGO; it does not parse the SVG or rewrite path data.

## Features

- Upload a .svg file or paste SVG code
- Always strips the <?xml ... ?> declaration
- Toggleable passes: remove comments; remove <metadata>, <title> and <desc>; remove editor namespaces and attributes (inkscape, sodipodi, sketch, illustrator, data-name); remove empty attributes; remove default values (e.g. opacity="1", stroke="none", stroke-width="1", fill-rule="nonzero")
- Shorten hex colors (#aabbcc -> #abc) and named colors white, black, yellow, cyan, fuchsia, magenta to short hex; only in color attributes and CSS color properties (fill, stroke, stop-color, flood-color, lighting-color, color), so ids and url(#...) references are never touched and 8-digit #rrggbbaa colors are left intact
- Optional Shorten IDs (off by default): renames every id to a short one (a, b, ...) and updates all in-file references: url(#id), href / xlink:href="#id", ARIA id lists (aria-labelledby, aria-describedby, ...), SMIL begin/end timing (id.end, id.click), and #id selectors in <style>; SVGs containing <script> are left unchanged
- Optional viewBox removal (off by default, marked caution) and whitespace minification (on by default)
- Before/after size in bytes and percent reduction, updated live
- Live preview of the result over a checkerboard, sanitized with DOMPurify (SVG profile)
- Copy and pipeline buttons on the optimized output; Download Optimized SVG saves optimized.svg (always available, with a note when the result is not smaller)

## How to use it

1. Click Upload SVG or paste SVG code into the input box
2. Adjust the optimization checkboxes if needed
3. Compare the sizes and check the preview
4. Copy the optimized code or click Download Optimized SVG

## Inputs

- SVG markup as text, pasted or from a .svg file

## Outputs

- Optimized SVG text (copy or send to another tool)
- optimized.svg download

## Limits and notes

- Regex-based, not an SVG parser: no path simplification, no removal of unused defs or empty groups
- Shorten IDs rewrites references inside the file only; CSS or scripts outside the SVG that target the old ids will no longer match
- Removing <title>/<desc> drops accessibility text, and removing viewBox can change scaling
- Nothing is saved to localStorage; files are read locally and never uploaded

## Questions and answers

### How does the SVG Optimizer work?

The tool runs a series of regular-expression cleanups over your SVG text. It always removes the XML declaration, then optionally strips comments, metadata/title/desc, editor namespaces and attributes (Inkscape, Sodipodi, Sketch, Illustrator), empty attributes and default attribute values, shortens hex and named colors, removes the viewBox and collapses whitespace. It does not parse the SVG or rewrite path data.

### How much smaller will my SVG be?

It depends on the file. SVGs exported from editors such as Inkscape or Illustrator usually carry metadata, comments and default attributes that this tool removes, while hand-written or already-minified SVGs shrink little. The tool shows the exact before and after size and the percentage saved.

### Will optimization change how my SVG looks?

With the default options it usually does not, because it removes comments, metadata, editor data and attributes set to their default values. Removing the viewBox (off by default) can change how the SVG scales, and removing title/desc drops accessibility text. Check the live preview before downloading.

## Related tools

- [Barcode Generator](https://overtooled.com/barcode-generator.md): Generate single or bulk barcodes (EAN-13, UPC-A, Code 128, Code 39). Download as PNG or ZIP.
- [Base64 Encode/Decode](https://overtooled.com/base64.md): Encode text to Base64 or decode Base64 strings instantly
- [Chart Studio](https://overtooled.com/chart-studio.md): Create beautiful bar, line, pie, and scatter charts from your data
- [Code to Image Converter](https://overtooled.com/code-to-image.md): Create beautiful code screenshots with themes, window chrome, and PNG export

---
Overtooled: 179 free tools that run in your browser. Index of all tools: https://overtooled.com/llms.txt
