SVG Optimizer

Minify and clean SVG files in your browser, strip comments and metadata, round path precision. Free, private, no upload, with before/after size stats.

🌐 Español

Drop your files here (.svg)

🔒 Private by design: your files are processed locally in your browser and never uploaded to any server.

Where the bytes in an exported SVG actually go

An SVG is a text file, which is its great strength and the reason it quietly bloats. Nothing about an XML document tells you it has grown; you have to open it and look. When you do, an icon exported from a vector editor usually turns out to be mostly things that have no effect on the picture at all.

A representative export carries an XML declaration it does not need in a browser, a generator comment naming the application and its version, a <metadata> block describing the editing session, style rules for classes nothing uses, wrapper <g> groups left over from the layer panel, and coordinates specified to six or more decimal places when three render identically. On one icon that is a few hundred wasted bytes and nobody is harmed. On a design system shipping ninety inline icons to every visitor on every page, it is a tax paid over and over, and it lands on both transfer size and parse time.

Cleaning it up is one of the rare page-weight wins that is genuinely free. There is no quality slider to agonise over, because none of the removed material was drawing anything.

What SVGO’s default preset strips, and the two things it keeps

The work here is done by SVGO, the same optimizer that sits inside most build pipelines and design tooling, running its preset-default plugin set with multipass enabled so a second cleaning round can catch what the first one exposed. Nothing bespoke was written to reimplement it; the browser build of the library is imported directly and run in your tab.

That preset does considerably more than delete comments. It converts shapes to paths where a path is shorter, rewrites absolute path commands as relative ones, shortens colours (blue becomes #00f), collapses useless groups, drops unreferenced style blocks and removes attributes whose values were already the default. Its output is deliberately still a valid, re-parseable SVG; the test suite feeds the result back through the parser to prove it.

Two things are kept on purpose. <title> and <desc> survive, because they are what a screen reader announces and what a search engine reads, and shaving forty bytes off an icon by making it anonymous to assistive technology is a bad trade. This tool does not add an override to remove them, and it says so here rather than doing it silently.

It is also worth knowing what those <metadata> blocks can contain before you publish a logo: depending on the editor, the original file path on your disk, the application and version, an author name, or an embedded colour profile. Optimizing a file is a privacy step as much as a size step, and it happens entirely on your own machine here, so a client’s unreleased mark is not uploaded anywhere to have its own author metadata removed.

Choosing a precision, with real numbers

The precision option is the only judgement call. To make it concrete, here are real figures for the fixture this tool’s own test suite uses: a 484 byte Illustrator style export carrying an XML declaration, a generator comment, a <metadata> block, a <title>, a <desc>, an unused style rule, a <rect> and a <path> with coordinates written to six decimal places. Each row is that file put through the exact SVGO configuration this tool ships.

PrecisionOutputChange
6273 bytes43.6% smaller
3 (default)246 bytes49.2% smaller
2234 bytes51.7% smaller
1226 bytes53.3% smaller
0210 bytes56.6% smaller

Two things stand out. Most of the saving is already banked before precision enters the picture, because deleting the declaration, the comment, the metadata and the dead style rule is the bulk of the win. And the curve from 3 down to 0 is shallow: the 36 bytes between them are rarely worth introducing rounding you then have to reason about. That same run also shows the other rewrites happening in the same pass, since the <rect> comes back as a <path> and stroke="blue" comes back as stroke="#00f", while the <title> and <desc> are still there untouched.

The default of 3 is SVGO’s own upstream default and the right answer for icons and UI graphics. Go down to 1 or 2 for large illustrations with thousands of path points, where the per number saving multiplies into something real. Go up to 5 or 6 when coordinates carry meaning beyond display, such as a map, a technical drawing or a file that will become a machine toolpath.

Running a batch, and reading the stats comment

Four steps, and one of them is optional:

  1. Drop one file or a folder’s worth of .svg into the box above, or click Choose files.
  2. Set Decimal precision for coordinates/path data (0–6, lower = smaller file) if the default of 3 is not what you want.
  3. Click the action button, which reads SVG Optimizer.
  4. Download each result and read the stats comment on its first line.

Files are processed one at a time with the progress bar advancing per file, which is effectively instant for text this small. Each result is offered as a download named after the original with -optimized appended, so icon.svg becomes icon-optimized.svg and your source file is never modified.

The first line of every output is a comment like this:

<!-- svg-optimizer: 1000 -> 500 bytes (50.0% smaller); gzip estimate ~300 bytes -->

The gzip figure is not a rule-of-thumb multiplier. It is produced by actually gzipping the optimized markup with the browser’s native compression API, borrowed from the CSS Minifier, which shares this reporting format. That number is the one to care about if you serve the file over HTTP with compression on, and it explains a result that surprises people: heavy repetition in path data compresses extremely well, so a file that shrinks 40 percent raw may only shrink 15 percent over the wire.

What this will not do for you

SVGO is a text optimizer, so its limits follow from that. It will not rasterize (use SVG to PNG when a platform refuses vectors), it will not vectorize a bitmap (that is PNG to SVG), and it will not recompress a base64 raster image embedded inside the markup, which is the single most common reason an SVG stays stubbornly large. It does not merge multiple files into a sprite sheet, does not subset embedded fonts, and cannot convert text elements to outlines.

It is also strict where a CSS minifier is forgiving. Feed it broken markup and it stops with a clear Invalid SVG file error instead of writing something plausible-looking and corrupt, which is the behaviour you want from a tool whose output you are about to commit. An empty file is the one exception and is handled quietly.

See it in action

Screenshot of the SVG Optimizer tool with sysfenix-sample.svg (353 B) loaded, Decimal precision for coordinates/path data (0–6, lower = smaller file) set to 3
SVG Optimizer mid-process: sysfenix-sample.svg (353 B) loaded, Decimal precision for coordinates/path data (0–6, lower = smaller file) set to 3.
Screenshot of the SVG Optimizer result screen showing sysfenix-sample-optimized.svg ready to download (411 B, 16% larger)
The finished result: sysfenix-sample-optimized.svg ready to download (411 B, 16% larger). The download link is a local blob URL — the file never leaves your device.

Frequently asked questions

What does the precision setting actually change?

It sets how many decimal places numeric values keep, both in plain coordinates and inside path data. A coordinate written as 10.123456 by your editor becomes 10.123 at the default of 3, or 10.1 at 1. Values outside 0 to 6 are clamped rather than rejected, and a fractional setting is rounded, so 2.6 becomes 3.

Will optimizing change how my SVG looks?

The cleanup itself is designed to be visually lossless, so comments, metadata and redundant attributes go without affecting a single rendered pixel. Precision rounding is the one setting that can, in principle, move a point by a fraction of a unit; at 3 decimals on a normal icon viewBox that is far below one screen pixel. Keep precision at 5 or 6 if you need coordinates preserved exactly, for example in a file destined for a CNC or plotter toolpath.

Why is my title and description still in the file?

Because removing them would quietly break accessibility. The title element is what a screen reader announces for an inline SVG, and search engines read it too, so SVGO's default preset keeps both title and desc and this tool does not override that. Delete them yourself if a decorative icon genuinely does not need them.

I got an "Invalid SVG file" error. What causes that?

SVGO parses your file properly rather than treating it as loose text, so genuinely malformed markup (an unclosed tag, or a file that is not SVG at all despite the extension) stops the run instead of producing corrupted output. Open the file in a text editor and look at the tags; a file exported straight from Illustrator, Figma, Sketch or Inkscape will not trip this.

My SVG has a photo embedded in it and barely got smaller. Why?

Because an SVG that embeds a base64 raster image is mostly that image, and SVGO does not recompress bitmap data. Strip the embedded picture out, run it through the Image Compressor separately, and re-embed it, or reference it as an external file instead.

What is the comment at the top of the output for?

It records the before and after byte counts, the percentage change and a real gzip measurement of the optimized markup, so you can see what the run bought you. It is a valid XML comment placed before the root element, so the file is still a usable SVG, and the roughly 80 bytes it adds are not counted in its own "after" figure. Delete that one line if you want the smallest possible file.

Related tools