SVG Optimizer
Cut the bloat out of an exported SVG — comments, editor leftovers, default attributes and over-long coordinates.
What this tool does
SVG Optimizer walks the markup token by token and drops the parts that carry no drawing instruction: comments, the XML declaration and DOCTYPE, <metadata> and the RDF and Creative Commons licence blocks inside it, attributes from a fixed list — version, opacity, stroke-width, stroke-linecap, fill-rule and a dozen more — that are still holding their specification default, and everything left behind by an editor's own namespace — inkscape:, sodipodi:, sketch:, figma:, illustrator: and the rest, along with the xmlns declarations that introduce them. Coordinates in path data, transforms, the viewBox and the geometry attributes are rounded to the number of decimals you set.
Editor exports are verbose for reasons that made sense inside the editor. A shape nudged by hand ends up with eight or nine decimal places per coordinate, which is precision no renderer can show; layer names, guides and page setup are written back into the file so the drawing reopens the way you left it; and paint attributes are stated explicitly even when they match the default, so fill-opacity="1" and stroke-width="1" repeat on every node. None of that reaches the screen, and all of it is paid for on every request when the icon is inlined in HTML or carried in a CSS data URI.
This is a text-level rewriter, not the SVGO plugin chain. It will not merge or re-encode path data, convert shapes to paths, collapse nested groups, rewrite the CSS in a <style> block, round numbers written into a style attribute, or touch a raster image embedded as a data URI — so if a stray 400 KB PNG is what makes your file heavy, nothing here will find it. Rounding is where the drawing itself changes, and it cannot be undone: at zero or one decimal place a large drawing can visibly shift, so look at the result before you ship it. Beyond checking that an <svg> element is present, nothing validates the markup, because the output is never re-parsed — and one malformed case is actively lossy: an attribute written without quotes, width=5 rather than width="5", is not recognised and disappears. Quote everything in a hand-edited file before you run it through.
The whole pass happens in this browser tab: what you paste stays in the page, no request carries it anywhere, and the result is identical with the network switched off. Read that as privacy, not as safety. This is not a sanitiser — a <script> element, an onclick attribute or a reference to an external file all come through untouched, because stripping those is a different job from making a file smaller. An SVG from a source you do not trust is no safer for having been through here, and should not be inlined into a page on that basis.
How to use it
- Paste the SVG source. Open the .svg in a text editor and paste the whole thing, or press Load sample to see a typical editor export. One document per run — there is no file picker and no batch mode, and a gzipped .svgz has to be decompressed first.
- Pick the rounding precision. Two is the default and is safe for a 24px icon, where a hundredth of a unit is far below a pixel. Raise it towards six for large artwork, a map or anything with a big viewBox; drop it to zero only on a grid-aligned drawing.
- Choose what may go. Comments, declarations, metadata, editor namespaces, default attributes and whitespace are removed by default. Removing <title> and <desc>, and removing ids that nothing references, are both opt-in.
- Read the summary, then take the result. The line under the output gives bytes before and after, the percentage saved and counts of comments, elements and attributes removed. Copy the markup, or download it as optimised.svg.
Processing & privacy
Runs on your device. Your file is processed directly in this browser.
Common use cases
Icons going into a sprite sheet
A sprite repeats the same waste across dozens of glyphs, so trimming metadata and precision once per icon compounds across the whole set.
A logo inlined in HTML
Inline SVG is part of the document, not a cached asset, so its bytes are paid for on every page load rather than once.
An export straight out of a vector editor
Layer names, guides, page setup and the editor's namespace declarations describe the workspace, not the drawing, and none of it is read by a browser.
Committing artwork to a repository
Running each version through with the same settings normalises formatting and precision, so the git diff shows shapes that actually changed instead of re-serialised coordinates.
Questions
Is my SVG uploaded anywhere?
Is this SVGO?
Can it change how the drawing looks?
Why are <title> and <desc> kept by default?
Why is removing unused ids switched off?
How much smaller will my file actually get?
Can I open a file with it, or export a PNG?
Related tools
- HEX to RGB — Convert a hex colour to RGB values.
- WCAG Contrast Checker — Test colour pairs against AA and AAA thresholds.
- RGB to HEX — Convert RGB values to a hex colour.
- HEX to HSL — Convert hex to hue, saturation and lightness.
- HSL to HEX — Convert HSL values back to a hex colour.
- CMYK Converter — Convert between RGB and CMYK for print work.