SVG Optimizer
Optimize SVG in your browser: strip comments, metadata and unused defs, collapse transforms and shorten hex, with a before/after preview and gzip size.
SVG Optimizer — Drop, upload or paste raw SVG exported from Illustrator, Figma or Sketch, and this optimizer removes what bloats the file — comments, metadata/title/desc, editor namespace attributes, empty groups, unused IDs and unreferenced defs — and can round coordinates, collapse redundant transforms, minify inline styles, shorten hex colors and drop default attribute values. A side-by-side render lets you confirm nothing broke, and it reports raw, gzip and estimated brotli sizes. Everything runs locally with the browser's DOMParser, so no SVG is ever uploaded.
What is SVG Optimizer?
The SVG Optimizer is a free, in-browser tool for web designers, icon authors and front-end developers who need to trim hand-written or exported SVG before shipping it. Vector editors add invisible weight: XML comments, metadata blocks, Inkscape/Sodipodi/Illustrator attributes, redundant decimals, no-op transforms, wrapper groups, and IDs and defs nothing references. Turn each cleanup on or off in Settings, then paste the markup or drop an .svg file, watch the Original and Optimized renders update side by side, and read the Before, After, Saved, Gzip and Brotli stats to confirm the gain. Copy the result or download it as a .min.svg. Use it to lighten inline icons, sprite sheets, logos and illustrations.
How to use SVG Optimizer
- Paste your SVG, or drop/upload an .svg file — the markup fills the input box.
- Open Settings and toggle exactly the cleanups you want: round coordinates, remove comments, metadata and editor attributes, empty groups, unused IDs and defs, collapse transforms, minify inline styles, shorten hex colors, drop default values and minify whitespace.
- If coordinate rounding is on, set the precision (0-5 decimals).
- Compare the Original and Optimized renders side by side to confirm the artwork still looks right.
- Read the Before, After, Saved, Gzip and Brotli stats to see the real size gain.
- Copy the optimized SVG, or download it as a .min.svg file.
Examples
Strip an editor comment and metadata
Input
<svg xmlns="http://www.w3.org/2000/svg"><!-- Generator: Sketch --><title>icon</title><rect x="0" y="0" width="24" height="24"/></svg>
Output
<svg xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="24" height="24"/></svg>
Round long coordinates
Input
<svg xmlns="http://www.w3.org/2000/svg"><path d="M1.00000 2.49999 L10.333333 8"/></svg>
Output
<svg xmlns="http://www.w3.org/2000/svg"><path d="M1 2.5 L10.33 8"/></svg>
Shorten hex colors and drop default values
Input
<svg xmlns="http://www.w3.org/2000/svg"><rect fill="#FFFFFF" fill-opacity="1" width="24" height="24"/></svg>
Output
<svg xmlns="http://www.w3.org/2000/svg"><rect fill="#fff" width="24" height="24"/></svg>
Frequently asked questions
- What exactly does the optimizer remove?
- With the matching toggles on: XML comments, <metadata>, <title> and <desc> elements, editor namespace attributes (Inkscape, Sodipodi, Illustrator), empty groups, IDs that nothing references and unreferenced <defs>. It can also round numeric attributes and path data, collapse no-op transforms, minify style attributes and <style> CSS, shorten hex colors (#ffffff to #fff) and drop default presentation attributes such as fill-opacity="1".
- Will rounding coordinates change how my SVG looks?
- Rounding to a low precision can shift points by a tiny fraction of a unit, usually invisible but smaller. Raise the precision (up to 5 decimals) for exact geometry, or turn coordinate rounding off to keep numbers untouched.
- Can I load a file and preview the result?
- Yes. Drop or upload an .svg file (or paste the markup) and the Original and Optimized renders appear side by side so you can spot anything that broke. Then copy the output or download the optimized .min.svg — nothing is uploaded; the file is read locally.
- What do the Gzip and Brotli figures mean?
- The Gzip size is measured by actually compressing the optimized SVG in your browser, so it reflects the real bytes over a gzip-enabled connection. The Brotli figure is an estimate derived from that gzip size (brotli usually compresses text a little smaller); a real brotli encoder is too heavy to bundle, so it is marked with a tilde.
- Is my SVG uploaded anywhere?
- No. Parsing, cleanup, size measurement and serialization all happen locally in your browser with the built-in DOMParser. Nothing is sent to a server, so the tool works offline and your artwork stays private.
Related tools
Code to Image
Turn a code snippet into a syntax-highlighted image in your browser, with 20+ languages, custom themes and backgrounds, line numbers, and PNG or SVG export.
Color Contrast Checker
Check the WCAG 2.1 contrast ratio and APCA Lc score between text and background colors, see AA, AAA and 3:1 badges, and apply the nearest passing color.
Color Mixer
Blend two HEX colors at a chosen ratio in RGB or Lab color space and read the resulting mid color back as a swatch and copyable HEX value.
Color Shades Generator
Turn one base HEX color into a perceptual OKLCH, HSL, or RGB shade scale with adjustable stops, WCAG contrast hints, and CSS, Tailwind, and JSON export.