SVG Minifier

· Free browser tool

An SVG minifier removes the parts of an SVG file that a browser never needs to render it: editor comments, <metadata> blocks, Inkscape and Sodipodi namespaces, the XML declaration and DOCTYPE, and the whitespace that sits between tags. The image looks identical, but the file weighs noticeably less, which trims page weight and speeds up the icons, logos, and inline illustrations that load on every view.

This tool minifies pasted SVG markup in the browser using a real parser to confirm the input is valid SVG before and after compression, so path data and live <text> are never broken. It is free, needs no upload, and shows the original versus minified byte count with the exact percentage saved.

SVG MinifierFree · client-side
Options
Minified output
Original
Minified
Saved

        Live render of result
        

🔒 Private: everything runs in your browser. Nothing you paste is uploaded.

How to minify SVG safely

Paste your SVG, choose which parts to strip, and click Minify. The tool validates the markup with DOMParser, compresses only the safe cruft, and re-checks the result before showing it so you never copy a broken file.

Strip the editor cruft, not the rendering instructions

Most of the weight in a hand-saved SVG is invisible to the browser. Design tools inject <metadata>, a <title>, comments, and editor-only namespaces such as inkscape: and sodipodi: that carry no visual meaning. The minifier removes those, drops the optional XML declaration and DOCTYPE that inline SVG does not need, and collapses the whitespace between tags. What it never touches is the geometry: path d data, coordinates, fills, and viewBox stay intact, so the rendered image is byte-for-byte identical on screen.

Protect text, paths, and scripts from whitespace collapse

Collapsing whitespace is where naive minifiers break files. Spaces inside a <text> element are visible content, and a stray newline removed from path data or a <style> block can corrupt the drawing. This tool isolates <text>, <tspan>, <style>, and <script> bodies before it touches whitespace, transforms only the structural markup around them, then restores those blocks untouched. It also re-parses the minified output and refuses to show it if the result is no longer valid SVG.

Use precision trimming carefully on path-heavy art

Vector editors often export coordinates with six or more decimal places, like 60.000000, when one or two is visually indistinguishable. The optional precision setting rounds the numbers inside attribute values and strips trailing zeros, which can shrink path-heavy illustrations substantially. It is off by default because aggressive rounding can shift detailed artwork. Start at two decimals, watch the live preview, and back off if any curve drifts. Coordinates inside text content are deliberately left alone so labels never change.

SVG minifier frequently asked questions

Q1Will minifying change how my SVG looks?

No, with the default options. The tool only removes comments, metadata, editor namespaces, the XML declaration, and whitespace between tags, none of which affect rendering. The geometry, fills, and viewBox stay intact, and a live preview renders the result so you can confirm it matches. Precision trimming is the one option that can alter appearance, which is why it is off by default.

Q2Is it safe to remove the XML declaration and DOCTYPE?

For SVG embedded inline in HTML or used as an icon, yes. Modern browsers render SVG without the XML declaration or a DOCTYPE, and the SVG specification does not require a DOCTYPE. If you serve a standalone .svg file that a specific legacy tool insists on declaring, you can leave that option unchecked and still strip everything else.

Q3Does this SVG minifier upload my files anywhere?

No. Everything runs in your browser with client-side JavaScript. The markup you paste is parsed, minified, and previewed locally, and nothing is sent to a server, logged, or stored. The tool keeps working with no network connection once the page has loaded, which makes it safe for unreleased logos or confidential brand assets.

Q4Why is the percentage saved different for each file?

Savings depend on how much non-rendering content the original carries. A file exported from a heavy editor with metadata, comments, and editor namespaces can shrink dramatically, while a file already hand-written for the web may be near minimal and save little. The tool shows the real original and minified byte counts so you see exactly what was removed rather than a generic estimate.

Q5Should I also gzip my minified SVG?

Yes, the two stack. Minifying removes redundant bytes from the source, and gzip or Brotli compression on the server squeezes the rest in transit. Minifying first gives the compressor cleaner input and a smaller transfer in the end. Enable text compression on your server or CDN for SVG, and serve minified markup as the source for the best combined result.

Hristo Bogdanov, Head of SEO at SEO Domains

Hristo Bogdanov

Head of SEO @ SEO Domains · CEO & Co-founder of SEO.bo

Hristo has spent 15+ years building aged-domain acquisition and screening workflows for SEO professionals, brand owners, and domain investors, and builds the free tooling SEO Domains publishes for practitioners.