Updated: July 5, 2026
Compressing an SVG online means removing redundant XML markup, not lowering pixel quality. Use a browser-based optimizer, keep the viewBox, preserve any IDs referenced by gradients, masks, CSS, scripts, or accessibility labels, and compare the result before publishing. For a quick, local workflow, LessMB compresses SVG and other image files directly in your browser without uploading them. When you need to inspect or toggle individual SVGO plugins, SVGOMG or the SVGO CLI gives you that control — then verify the output before you ship.
The safety argument rests on one key difference: SVG is XML text, not a pixel grid. Cleaning up the markup is lossless. The goal is a smaller file that looks the same in the browser. The only things that can break are references and runtime behaviors the optimizer was not told about — IDs, viewBoxes, hidden layers toggled by JavaScript. Everything below is about protecting exactly those.
Key Takeaways
- SVG optimization is lossless markup cleanup, not pixel reduction — a correctly optimized file renders identically to the original.
- Four plugins cause almost all real-world breakage:
removeViewBox,cleanupIds,removeDimensions, andremoveHiddenElems. Review them before exporting. - Editor exports are bloated by default; meaningful size savings are common, especially on raw Illustrator, Figma, or Inkscape files.
- Prefer a browser-based tool so sensitive artwork is never uploaded to a third-party server.
- Optimize the markup first, then serve with gzip or Brotli — the two layers stack.
What SVG Compression Actually Removes
An SVG is not a bitmap. It is an XML document containing <path>, <circle>, and <rect> elements plus styling attributes. Optimizing it means deleting data the browser ignores, dropping attribute values that merely repeat the SVG specification's defaults, shortening numbers below subpixel precision, and collapsing redundant nesting.
Because no pixels are sampled and discarded, an optimized SVG is rendering-equivalent to the original. The only risks come from the handful of plugins covered in the next section.
What Gets Removed
According to the SVGO preset-default documentation, the standard optimization pass removes:
- Editor metadata and namespaces. Illustrator embeds
xmlns:ai, Inkscape writessodipodiandinkscapenamespaces with grid and guide data, and Figma adds a metadata block. Browsers ignore all of it. - XML declaration and comments. The
<?xml version="1.0"?>header and<!-- comments -->are not required for browser rendering. - Empty containers. Leftover
<g>tags from deleted layers anddisplay:noneconstruction helpers disappear. - Default presentation attributes. Values like
fill-opacity="1",stroke="none", anddisplay="inline"duplicate the SVG specification's defaults, so dropping them has no visual effect. - Excess coordinate precision. Path data from design tools often ships 8–16 significant figures. At small display sizes the difference between
123.456789and123.46is a fraction of a subpixel — invisible at normal screen resolutions.
The Plugins That Actually Break SVGs
Not every optimization is safe to apply blindly. The table below covers the settings most likely to cause breakage. Because plugin defaults can change across SVGO versions, verify the current state in your tool before exporting.
| SVGO plugin | Typical default | What it does | Risk | Safe to enable when |
|---|---|---|---|---|
removeViewBox | Off | Deletes the viewBox attribute when width and height exist | Breaks proportional scaling; CSS width:100% stretches or clips the image | Generally avoid for responsive SVGs — SVGO docs warn it can prevent scaling |
cleanupIds | On | Shortens id values to compact hashes | Breaks getElementById, CSS #id rules, aria-labelledby, and url(#grad) fragment references; raises collision odds when multiple SVGs are inlined on the same page | Standalone <img src> files only — turn off for inline SVG |
removeDimensions | Off | Removes width and height, leaving only viewBox | SVG becomes invisible if the container has no defined size (common in email and plain HTML) | Only when you always size via CSS and a viewBox is present |
removeHiddenElems | On | Deletes elements with display:none or visibility:hidden | Breaks JavaScript that toggles visibility at runtime | Off for JS-animated or interactive SVGs |
mergePaths | On | Combines multiple paths into one | Can change visual stacking when paths overlap with transparency | Review the output visually before shipping |
The removeViewBox plugin deserves emphasis. The viewBox defines the SVG's internal coordinate system; without it the graphic cannot scale proportionally. The SVGO removeViewBox documentation notes that it can prevent SVGs from scaling — leave it disabled for any SVG used in a responsive layout.
cleanupIds is the other common trap. It is on by default and fine for a standalone file served as <img src>. Turn it off whenever the SVG will be inlined in HTML, because external JavaScript, CSS, and ARIA attributes may reference its original IDs. See the SVGO cleanupIds documentation for the full behavior.
Best Settings by SVG Use Case
Use this table to pick your settings before you export. Verify the result visually after each run.
| SVG use case | Keep off | Extra check |
|---|---|---|
Standalone file served via <img src> | removeViewBox | Scales correctly at different container widths |
| Inline SVG in HTML (themed by CSS or scripted by JS) | removeViewBox, cleanupIds, removeHiddenElems | Gradients, masks, and url(#…) references still resolve; JS interactions fire |
| Animated SVG (SMIL or CSS animations) | removeViewBox, removeHiddenElems | Animations play as expected in the browser |
| Logo or icon (brand colors, accessibility label) | removeViewBox; review minifyColours, removeTitle, removeDesc | Brand colors are accurate; <title> and <desc> survive if needed for screen readers |
Which Tool Should You Use?
| Tool | Best for | Plugin control | File stays local? |
|---|---|---|---|
| LessMB | Quick browser-based SVG and image compression without configuration | No per-plugin toggle | Yes — processed in your browser |
| SVGOMG | Inspecting and toggling individual SVGO plugins before exporting | Full access to many SVGO options | Yes — runs entirely in-browser |
| SVGO CLI | Build-pipeline automation; batch processing; custom config files | Complete, version-controlled config | Local — runs in your terminal |
For most designers and developers shipping a single SVG or a small batch, LessMB is the fastest path: open the file, compress it locally, and download the result. When you need to audit which plugins are active or tune number precision for a complex illustration, move to SVGOMG, which gives you a live preview alongside the size counter. For repeatable automation, wire SVGO into your build pipeline so every SVG is optimized once at compile time.
Safe SVG Compression Workflow
This is the conservative, break-proof workflow using a browser-based optimizer. It works with SVGOMG or any tool that exposes SVGO plugin settings.
- Open the file in a browser-based optimizer. In SVGOMG, click Open SVG or use Paste markup. Confirm the tool processes locally — the file should not be uploaded to a server.
- Set number precision to 3. For a detailed illustration with fine curves, try 4 or 5 and compare; for simple icons, 2 is often invisible. Lower values give smaller files but can subtly affect curved paths.
- Confirm the risky plugins are off. Make sure Remove viewBox is unchecked. If the SVG will be inlined or styled by CSS, uncheck Clean up IDs too. Uncheck Remove hidden elements if JavaScript toggles parts of the graphic.
- Protect accessibility and branding. Leave Remove
<title>and Remove<desc>unchecked if you rely on them for screen readers. Review Minify colours on brand illustrations where named colors carry meaning. - Watch the byte counter and preview. SVGOMG shows before-and-after sizes and a live rendered preview. Toggle Compare gzipped to see the over-the-wire size.
- Copy or download the result, keeping your original until you have run through the verification checklist below.
Verifying Nothing Broke
Optimization is only "safe" if you check the result. Run through this checklist before you ship the file.
- Scales correctly. Drop the SVG into a container, resize the window, and confirm it scales proportionally rather than stretching or clipping (this catches a stripped
viewBox). - Gradients, masks, and filters render. Look for any
url(#…)reference that has gone missing or turned flat black. - CSS theming still works. If you use
currentColoror external CSS, confirm colors still apply. - IDs still resolve. Search the optimized markup for the IDs your gradients, masks, or scripts reference.
- Accessibility text survives. Confirm
<title>and<desc>are still present if you depend on them for screen readers. - Animations and interactions fire. For SMIL or JavaScript-driven SVGs, test the actual behavior in the browser, not just the static preview.
If something failed, it is almost always one of the four plugins in the table above. Re-enable the one you switched off and re-optimize.
Compress Privately: Checking the Upload Model
Some online tools require you to upload your SVG to a server, process it there, and download the result. Before using any tool with sensitive or proprietary artwork, check its documentation or privacy policy to confirm whether files are transmitted.
Browser-based tools process the file entirely in your local environment. LessMB and SVGOMG both fall into this category — your SVG is never sent to a remote server. For anything confidential, that is the category worth using.
SVG Optimization vs Gzip and Brotli
SVG optimization and HTTP compression are not the same job. Optimization strips redundant markup before the file is served. Gzip and Brotli compress the transport — the bytes on the wire. They operate on different layers, and using both gives the smallest payload.
Optimize first, because it removes structure that transport compression cannot fully dedupe (redundant groups and editor namespaces still cost something even after gzip). Then let your server or CDN apply Brotli or gzip. For SVGs used above the fold or across a large icon set, smaller text assets can reduce transferred bytes; verify the impact with Lighthouse or PageSpeed Insights.
FAQ
Is it safe to compress SVG files online?
Yes, provided you use a browser-based tool that processes the file locally and you leave the risky plugins off. The main safety lever is privacy: check whether the tool uploads your SVG to a server before using it with sensitive or proprietary artwork. SVGOMG and LessMB both process files locally.
Does SVG optimization reduce image quality?
No. SVG optimization removes redundant markup — metadata, comments, default attributes, and subpixel coordinate precision — not pixels. The rendered image should be identical. The only quality risks come from the handful of plugins that change references or behavior, which is why the safe workflow leaves those off.
Why did my SVG break after compression?
The usual cause is one of four plugins. removeViewBox deletes the coordinate system so the graphic no longer scales proportionally. cleanupIds renames an ID that a gradient, mask, CSS rule, or script referenced. removeDimensions strips size that an unsized container cannot replace, making the SVG invisible. removeHiddenElems deletes layers that JavaScript toggles at runtime. Re-enable the plugin you switched off and re-optimize.
Should I gzip my SVGs or optimize them?
Both. Optimize the markup first to remove redundancy that server compression cannot fully dedupe, then serve with gzip or, preferably, Brotli. Optimization works on the source; HTTP compression works on the transport. They stack, and using both gives the smallest delivered payload.
Which online SVG compressor should I use?
It depends on your workflow. For quick browser-based compression without configuration, LessMB handles SVG and other image files locally. For plugin-level control — inspecting and toggling individual SVGO options before exporting — use SVGOMG, which runs entirely in-browser and offers a live preview. For build-time automation, use the SVGO CLI or a bundler plugin.
Can I compress SVG files with LessMB?
Yes. LessMB processes files locally in your browser, so your SVG is not uploaded to a server. It is a good fit for straightforward, fast compression. When you need to audit or adjust individual SVGO plugin settings, use SVGOMG or the SVGO CLI and then verify the output.
Do online SVG compressors upload my file?
Some do, some do not. Browser-based tools process the file in your local environment without transmitting it. Before using any tool with proprietary artwork, check its documentation or privacy policy to confirm whether files are uploaded to a remote server.
What settings should I avoid for inline SVGs?
Turn off cleanupIds whenever the SVG will be inlined in HTML, because external JavaScript, CSS, and ARIA attributes may reference its original IDs. Also turn off removeHiddenElems if JavaScript toggles parts of the graphic at runtime. Leave removeViewBox disabled for any responsive use.
References
- SVGO preset-default documentation — what the standard optimization pass removes
- SVGO
removeViewBoxplugin documentation — why disabling it protects responsive scaling - SVGO
cleanupIdsplugin documentation — ID rewriting behavior and inline SVG risks - SVGO
removeDimensionsplugin documentation — when removing width/height is safe - SVGOMG — browser-based interface for SVGO with live preview and plugin toggles
- LessMB — browser-based SVG and image compression without upload
- LessMB: How to compress SVG files without breaking icons or logos — icon- and logo-specific optimization guidance
- PageSpeed Insights — verify load performance impact after optimization