The Complete SVG Optimization Guide
Learn how to reduce SVG file size by rounding coordinates, stripping editor metadata, flattening groups, and cleaning path data — without changing how the artwork looks.
An SVG that looks fine on screen can still be ten times larger than it needs to be. The excess usually comes from four places: coordinates carried to absurd precision, editor metadata that no renderer uses, redundant groups and transforms, and path data that repeats points along a straight line. This guide walks through each source of bloat and the specific techniques that remove it without touching what the artwork looks like.
Why SVG files get large
Vector size is not about how complex the picture looks. It is about how many numbers the file contains and how many digits each number uses. A single path with 20,000 nodes and six-decimal coordinates can dwarf an entire illustration composed of elegant 30-node curves. Design tools frequently emit that kind of file because they round-trip every editor state — named layers, unused swatches, viewport settings, and plugin data.
The best way to understand the problem is to open the SVG in a text editor and look at a path. If you see something like d="M 12.384756 -4.293847 L 12.384756 -4.100000 L 12.384756 -3.900000", you are looking at two distinct costs: numeric precision and unnecessary intermediate points. Removing a few decimal places loses nothing a printer or screen can detect. Removing collinear points loses even less.
Step one: reduce coordinate precision
A machine can distinguish roughly 0.05 of a millimetre. Print at 300 dpi resolves about 0.08 of a millimetre. Yet many exports carry six decimals of a millimetre, which is a sub-nanometre claim. Rounding path coordinates to two or three decimals is usually invisible in output and cuts file size dramatically, because every trailing digit costs one byte in a text format and many paths repeat coordinates hundreds of times.
If your file uses viewBox units where 1 unit equals 1 pixel, two decimals is plenty; if 1 unit equals a millimetre, three decimals is generous. If you are worried about rounding drift across many small segments, apply the rounding to every coordinate once rather than repeatedly optimizing an already-rounded file.
Step two: strip editor metadata
- Comments and descriptions — Inkscape and Illustrator both write history and tool notes that renderers ignore.
- Editor-specific namespaces — sodipodi, inkscape, sketch, and adobe attributes are not needed by browsers or cutters.
- Unused defs — gradients, clip paths, and symbols that nothing references.
- Empty groups and stray elements — zero-size rectangles, anchors, and hidden groups left from editing.
These are safe removals because they do not change the rendering model. The one caution is accessibility: preserved
Step three: flatten redundant structure
Design tools build hierarchy to make editing pleasant: a group that contains one group that contains one path, with a transform on each level. Rendered output collapses that structure anyway, so a file can be flattened without visual change. Nested identity transforms, empty groups, and duplicated clip paths are the usual offenders.
Transforms are subtler. A
Step four: clean the path data
Path data has its own predictable waste. Curves exported from tracing tools often contain points that sit on a straight line, which can be replaced by a single line command. Curved segments whose control points are collinear may have been straight lines all along. Repeated relative commands can use the implicit repetition rules of the SVG path grammar.
Do not add points by hand to "fix" a curve after rounding; that reverses the savings. Instead, look for genuinely redundant nodes: a smooth curve that was flattened during export can often be refit with fewer, more accurate beziers. This is the one operation that benefits from visual comparison, so preview at high zoom against the original.
Step five: embed or remove what you do not need
Embedded raster images are the largest thing in many SVGs. A base64 PNG inside an SVG is not vector art; it is a picture inside a wrapper, and it inflates the file by roughly a third over the binary size. If the image is decorative, consider whether the SVG needs it at all. If the SVG is destined for a cutter, embedded images usually cannot be cut and should be removed or traced into paths.
Fonts are the other embedding trap. Converting text to outlines guarantees the file renders anywhere and eliminates font dependencies, at the cost of a longer path list. If the SVG is for web display and the font is loaded by the page, keeping live text may be smaller. If the SVG is for production, outline it and remove the font block.
A safe optimization order
- Back up the original before editing.
- Remove comments, editor namespaces, and metadata.
- Delete unreferenced defs, symbols, and empty groups.
- Flatten unnecessary group and transform nesting.
- Round coordinates once, to a precision that fits the intended output.
- Collapse redundant path commands and collinear points.
- Outline or subset text according to the destination.
- Compare the optimized file against the original at 400% zoom before shipping.
Run the sequence in that order and most files shed a large fraction of their bytes in the first three steps alone. If a later step makes the file bigger, your tool is probably reintroducing precision or structure — check the settings before trusting the result. The right measure is not the smallest possible file, but the smallest file that still renders correctly on every target you care about.
Put this into practice
Upload an SVG and see exactly where the bytes go, or convert a raster image to a clean vector. No signup required to preview.