SVG Optimizer
Optimize and minify SVG files online with SVGO, in your browser. Choose a preset, compare the result visually and see the size and gzip savings.
Plugins
Removing the viewBox stops the drawing from scaling, and shortening or removing IDs breaks CSS, JavaScript, <use> or anchor links that refer to them. Keep the Safe preset for SVGs used in code, sprites or animations.
- Original size
- Optimized size
- Saving
- Gzipped
How to optimize an SVG
- Drop an SVG file on the drop zone or click it to choose one. You can also paste the markup into the SVG code box.
- Pick a Preset: Safe, Balanced (the default) or Maximum. The Plugins list below shows exactly which steps each preset turns on.
- Adjust if needed: the Decimal precision (0 to 8 digits), Multiple passes, and Pretty print (indented output) if you want readable code. As soon as you change a plugin, the precision or the passes, the preset switches to Custom.
- Click Optimize SVG. A dropped file is optimized right away, and once there is a result, every settings change re-runs the optimization automatically.
- Check the Original size, Optimized size, Saving and Gzipped figures, then compare the two drawings side by side.
- Click Copy to copy the Optimized SVG code, or Download optimized SVG to save it as
name.min.svg.
The optimization is done by SVGO 4, the standard open source (MIT) SVG optimizer used in most web build tools. Its browser version is loaded the first time you click, and it runs entirely on your device: your SVG is never uploaded.
Why SVG files from design tools are so heavy
An SVG exported from Illustrator, Inkscape, Figma or Sketch carries much more than the drawing. Editors add their own namespaces and attributes (layer names, guides, export settings), a <metadata> block, comments such as “Generator: Adobe Illustrator”, coordinates with six or more decimals, groups that contain a single element, and verbose colors like #ffffff. None of this changes what the browser draws. SVGO removes it, rounds numbers, rewrites path data with shorter commands, shortens colors and merges or unwraps redundant elements. A 40–60 % reduction is common for exported icons and illustrations.
Presets and risky plugins
- Safe runs SVGO’s default preset but keeps IDs,
<desc>, separate paths and<style>rules, with 3 decimals and one pass. Use it for SVGs referenced from CSS or JavaScript, sprites and animations. - Balanced is SVGO’s default preset, 3 decimals, multiple passes. It suits most icons and illustrations shown as images.
- Maximum adds Remove
, Remove scripts and event attributes, Remove width/height (keep viewBox) and Replace xlink:href by href, with 2 decimals and multiple passes.
No preset removes the viewBox. Remove viewBox is there for special cases only: without it, the drawing can no longer scale to the size you give it in CSS.
Know what the other plugins can break:
- Shorten and remove unused IDs renames IDs such as
#icon-hometoa. Any CSS selector, JavaScript query,<use href="#…">sprite reference, page anchor or SMIL/CSS animation targeting the old name stops working. - Remove
and Remove delete the accessible name and description. Keep them on meaningful icons and charts that screen readers must announce. - A low Decimal precision can deform small icons: curves wobble and edges drift. Always check the visual comparison; 3 is a safe default.
- Merge paths joins adjacent paths into one, so a hover effect or animation that targeted a single path loses its target.
Tips
- Keep an unoptimized master copy for editing; treat the
.min.svglike compiled code. - Enable gzip or brotli on your server: text formats like SVG compress very well, and the Gzipped figure shows what visitors actually download (shown when your browser supports
CompressionStream). - Inline SVG can be styled with CSS and animated but is not cached separately; an SVG in
<img>is cached but cannot be styled from the page.
Frequently asked questions
Is my SVG uploaded to a server?
No. SVGO runs in your browser. The only download is the optimizer code itself, the first time you optimize.
Why is the preview shown as images?
SVG is a document format that can contain JavaScript and load external files. Both previews are rendered as <img> from local blob URLs, and in that mode browsers never run scripts or fetch external resources, so previewing an untrusted SVG here is safe. The optimized code itself still contains any scripts unless Remove scripts and event attributes is on (it is in Maximum).
My optimized SVG no longer scales. What happened?
The viewBox was probably removed, either by Remove viewBox or earlier by another tool. Re-optimize the original with that plugin off.
Why did my icon sprite or animation stop working?
Shorten and remove unused IDs or Merge paths changed the elements your code refers to. Use the Safe preset, which keeps both.
The optimized file is not smaller. Why?
The SVG is probably already minified. Try Maximum or a lower Decimal precision, and turn off Pretty print (indented output).
Related tools
- SVG to PNG Convert SVG to PNG, JPG or WebP in your browser at any width, height, scale or DPI, with a transparent or colored background. Batch and ZIP, no upload.
- Image to SVG Tracer Convert a PNG or JPG logo or drawing to SVG vector paths in your browser. Presets, color count and speck filter, safe preview and download, no upload.
- Image Compressor Compress JPG, PNG and WebP images with a quality slider, compare sizes before and after, and batch-process photos without uploading them.
- CSS Formatter and Minifier Beautify messy CSS with clean indentation or minify it with csso, and see the size before and after. Runs in your browser; nothing is uploaded.