Decimal places in SVG: how much precision a drawing actually needs
Every number in an SVG is stored as text. The text can be as long as the exporter wants, and many exporters print six decimal places regardless of the display size. 12.000000 and 12 describe the same coordinate, but the first costs nine extra bytes. Across a path with hundreds of numbers, that formatting habit is often the largest removable cost after metadata.
Precision is a visual decision, not a mathematical one. What matters is the ratio between the rounding step and the size at which the image is displayed. A viewBox of 24 units shown at 24 px gives one user unit per CSS pixel, so rounding to 0.01 unit moves a point by one hundredth of a pixel. On a 3× phone screen that is three hundredths of a device pixel, far below what the eye resolves.
Choosing a precision by display size
| Drawing type | Suggested decimals | Reason |
|---|---|---|
| Icon at 16–32 px | 1–2 | Rounding error stays below a device pixel |
| UI illustration at 200–600 px | 2–3 | Large curves show a flat spot at one decimal |
| Logo or hero art at 1000 px or more | 3–4 | Fine curves and thin strokes need the detail |
| Map, chart or technical drawing | 3–4 | Coordinates are data, not decoration |
| Print or engraving file | 4 or source precision | The output device may resolve it |
Where the bytes are
Rounding saves in three ways. Trailing zeros disappear, so 1.500000 becomes 1.5. Leading zeros disappear in the short form the optimiser writes, so 0.5 becomes .5. And smaller numbers mean shorter relative coordinates, which makes the path rewriting pass more effective. On a typical editor export, two decimals removes five to twenty percent of the file before any other pass.
The order matters for measuring. If you round first and rewrite paths second, the path pass sees smaller numbers and can choose relative forms it would otherwise reject. If you rewrite first and round second, the output may contain redundant digits that the rewrite could have dropped. Either way the final difference is small, but the reported saving per pass will differ.
What rounding does not fix
Rounding cannot repair a path that was generated with far too many nodes. A curve approximated by two hundred line segments stays heavy at any precision. The fix there is to simplify the geometry in the editor, not to round harder. Similarly, rounding does not remove duplicate points or zero-length segments; a dedicated pass must detect them, and it must be careful because a zero-length segment with a round line cap is a dot that the drawing may rely on.
Keep the precision in the filename or in your build notes. A file optimised at one decimal looks fine in a preview and then shows faceting when someone scales it to a poster, and without the note nobody knows why.
A practical default is two decimals for icons, three for illustrations, and four for anything that will be printed or scaled far beyond its viewBox. Check the preview at the smallest size you ship and at the largest, because a rounding error that is invisible at 24 px can be obvious at 600 px.
Sources
Questions
Is two decimals enough for a 24 px icon?
Yes. Two decimals on a 24-unit viewBox gives a resolution of about 0.01 unit, which is 0.01 px at 24 px display size and 0.04 px on a 4× screen. The human eye cannot resolve that on an icon. Even one decimal is often acceptable, but fine curves and small radii benefit from two.
Why does my export have six decimal places?
Design tools store geometry as floating point and print it with a fixed format that does not know the final display size. A value such as 12.000000 is a formatting artefact, not extra information. Rounding removes digits that carry no visual meaning.
Can rounding break a shape?
It can flatten a very small detail: a curve whose control points differ by less than the rounding step becomes a straight line. That is why you check the preview. For logos displayed large, keep three or four decimals; for icons, two is the practical default.
Try the same file at one, two and three decimals and compare the preview with the byte count.
Open the optimizerWritten against the W3C SVG specifications, MDN and the React and WCAG documentation; every sample in the examples can be pasted into the optimizer linked above.
Back to the guides