Export an icon from a design tool and open the file in a text editor, and the drawing can be hard to find: comments come first, then a metadata block, elements named after the tool itself, groups inside groups, some of them empty. The picture is in there somewhere, wrapped in the record of its own editing session.
That wrapping is not a defect in your tool: an export is a working document, written so the project can be reopened and continued. Your website needs something else: the picture, and as little else as possible. This guide shows what design tools leave behind, how the free SVG Code Optimizer on Ovatly removes it rule by rule, and how to confirm the drawing survives untouched.
Contents
- Quick answer
- What your design tool leaves behind
- The cleanup rules and what each one removes
- How to clean up an export, step by step
- Worked example: a 393 byte export, cleaned
- How to verify the cleaned file
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Keep a copy of the original export, then paste the SVG code into the SVG Code Optimizer or load the .svg file. Leave the default rules ticked: comments out, editor leftovers removed, empty groups dropped, hex colors shortened and stray whitespace collapsed, with the XML declaration kept. Press Optimize SVG, check the result panel for both sizes, the saving percentage and the rules that fired, compare the two previews, and download the cleaned file once the picture matches.
What your design tool leaves behind
A design tool saves everything it might need when you reopen the project, and the export inherits all of it:
- Comments. Notes for humans, often including the tool's name and version. Browsers never render them.
- A metadata block. A
<metadata>element describing the file, its creator or its licensing. Useful in an archive, pure weight on a web page. - Namespaced editor elements. Tools such as Inkscape write their own elements, from the
sodipodiandinkscapenamespaces, recording the editing view and named paths. No browser uses them to draw. - Empty groups. A
<g>element that once held layers or shapes and now holds nothing. Exports accumulate them as artwork is rearranged, and an empty group draws nothing. - Longhand hex colors. A fill written as
#ffffffcosts three more bytes than#fff, for exactly the same color. - Generous whitespace. Indentation and blank lines between tags help editors read code and cost bytes on every download.
None of this is the picture: for a simple icon or logo, the paths and shapes are often a minority of the export's bytes, which is why cleanup pays off on every page using the file.
The cleanup rules and what each one removes
The optimizer works through a small set of rules, one per kind of leftover, and you tick the ones you want:
- Comments out deletes the XML comments.
- Editor leftovers removed deletes the
sodipodiandinkscapeelements and the metadata blocks. You lose the ability to recover those editor settings from this copy, one reason to keep the original. - Empty groups dropped removes
<g>elements with nothing inside them. - Hex colors shortened respells six-digit hex values in three digits wherever the color is unchanged, so
#ffffffbecomes#fff. - Stray whitespace collapsed reduces indentation and blank lines between tags to the minimum.
One rule is off by default: removing the XML declaration. Standalone files opened directly by other software sometimes rely on it, so it stays unless you choose otherwise, as when the SVG will be pasted inline into HTML.
Just as important is what no rule touches: path data, shapes, text and attribute values are never rewritten, so the drawing's geometry cannot change. Unlike a full minifier such as SVGO, the tool does not rename IDs, merge paths or round coordinates. The savings are smaller, and every change is visible and predictable.
How to clean up an export, step by step
- Export the SVG from your design tool and save a copy untouched. That copy is your editable source.
- Open the SVG Code Optimizer and paste the SVG code, or load the .svg file with the file box.
- Review the ticked rules. The defaults handle a typical export; add the XML declaration rule only if the file will live inline in HTML.
- Press Optimize SVG and read the result panel: both sizes, the saving percentage and the rules that actually changed something.
- Compare the previews: when the picture is identical, copy the cleaned code or download the file and ship that copy.
Worked example: a 393 byte export, cleaned
Take an exported icon of 393 bytes carrying an XML comment, a metadata block, a sodipodi:namedview element, an empty group and a rectangle filled with #ffffff. Through the default rules it comes out at 187 bytes, a 52.4 percent saving.
The result panel lists five rules fired, one for each kind of leftover. The rectangle itself is untouched except for its fill, now written as #fff, the same white in shorter spelling. More than half of the export was never picture; it was the editing session, written down.
Your numbers will differ: they depend on what your tool writes and how complex the artwork is. A busier illustration has proportionally less baggage, so its percentage will be smaller.
How to verify the cleaned file
Verification is built into the page and takes seconds. The result panel lists only the rules that actually fired, so the list is the complete record of what changed. The previews sit alongside, and the cleaned drawing should match the original exactly, shape for shape and color for color.
If the previews differ, do not ship the file: untick a rule and run the cleanup again, your untouched original still on disk. For animated or scripted SVG, test the cleaned version where it will run: whitespace inside a <style> block can be code.
Limitations and honest tradeoffs
The conservative rules are the main tradeoff: a hand-written SVG that was never inside an editor may save almost nothing, because there is no baggage to remove, and that is the tool working correctly, not failing. The optimizer also cannot judge whether a group is empty of meaning or only empty of elements, so files whose structure matters to your CSS deserve a close look at the previews.
Animated and scripted files need the caution mentioned above: the tool does not rewrite attribute values, scripts or style contents, but the whitespace rule collapses runs of whitespace, and inside a <style> block it can be meaningful. Keep the original either way.
Common mistakes
- Cleaning the only copy. The cleaned file is for shipping, not editing; the editor settings are gone from it.
- Removing the XML declaration on a standalone file. Software that opens the file directly may rely on it. Tick that rule only for inline use.
- Expecting minifier-level savings. No IDs are renamed, no paths merged. Predictability is the feature, and the percentage mostly measures editor baggage.
- Skipping the previews. They are the proof the picture survived: compare before you download.
- Editing the cleaned file. Regenerate the cleaned copy from the untouched source each time the artwork changes, rather than editing the cleaned version.
FAQs
What does a design tool add to an SVG export? Mostly records of the editing session: XML comments, a metadata block, elements from the sodipodi and inkscape namespaces, groups that ended up empty, longhand hex colors such as #ffffff, and generous indentation. Browsers ignore nearly all of it, but every byte still downloads.
Will cleaning up the export change how the SVG looks? No. The rules work on the markup around the drawing: path data, shapes, text and attribute values are never rewritten, hex colors are only respelled to the same color in shorter form, and the page shows before and after previews so you can confirm the picture is identical.
Can I choose which leftovers get removed? Yes. Every rule has its own tick box, and the defaults are conservative. The XML declaration, for example, is kept unless you tick its rule, which suits standalone files other software will open directly.
How much smaller will my exported file get? It depends on how much baggage the export carries. In the worked example below, a 393 byte export came out at 187 bytes, a 52.4 percent saving, with five rules firing. A clean, hand-written SVG has little to remove and may save almost nothing, a fine result.
Should I keep the original export after cleaning? Yes. The cleaned file is the shipping copy; the editor settings are gone from it, so it will not reopen as the same working document. Keep the original as your editable source and regenerate the cleaned version when the source changes.
Conclusion
A design tool export is a project file that happens to render. The SVG Code Optimizer strips the comments, leftovers and empty structure, shortens what can be shortened, and shows you the sizes, the rules that fired and both previews before you commit. Done carelessly, the same workflow has a failure mode worth knowing, covered in our guide to SVG optimization mistakes that break an icon. For more guides in this series, see our File and Data Conversion guides.
References
- MDN Web Docs, on SVG and how browsers render it: https://developer.mozilla.org/en-US/docs/Web/SVG
- W3C, the SVG 2 specification: https://www.w3.org/TR/SVG2/