Figma and Illustrator export vector paths with 6-8 decimal coordinate precision, inflating asset size. This tool cleans up path coordinate decimals, trims empty metadata and groups, and calculates real-time byte savings with side-by-side visual diff.
Technical guide on vector coordinate reduction, DOM bloat removal, and AST minification.
Architecture Overview
Vector design tools (Figma, Adobe Illustrator, Sketch) prioritize geometric accuracy over file efficiency, exporting path commands with 6 to 8 decimal places of floating-point precision. This excess precision results in sub-nanometer coordinate definitions that the human eye cannot perceive on display screens, inflating file sizes by 30% to 50%. This utility parses SVG path grammar to optimize numerical precision and strip dead XML nodes.
Core Mechanics & Implementation Details
Path Data Grammar (W3C SVG Path Spec)
SVG paths encode geometry via single-letter commands followed by coordinate parameters (M x y, C x1 y1 x2 y2 x y, Z). Floating-point coordinates are parsed into floating-point numbers and rounded to user-specified decimal thresholds using exponential rounding algorithms to prevent float precision drift.
Structural Dead-Code Pruning
Design tools export extensive metadata structures including <desc>, <title>, <metadata>, empty <g> container wrappers, and unused <defs> elements. Pruning these non-rendering nodes strips unnecessary bytes without impacting vector rendering pipelines.
Numerical Precision vs Visual Fidelity
On a standard 1080p display, 1 pixel represents approximately 0.26mm. A coordinate with 6 decimals (e.g. 12.384918px) defines precision down to the nanometer scale. Reducing precision to 1 or 2 decimals (12.4px) produces identical visual rasterization while stripping thousands of redundant ASCII characters.
Engineering Specifications
Parameter
Standard / Value
Engineering Scope
Grammar Parser
W3C SVG 2.0 Path BNF Spec
Command tokens: M, L, H, V, C, S, Q, T, A, Z
Rounding Algorithm
Exponential Float Decimal Clamping
Eliminates floating-point representation drift
Compression Range
20% to 55% Byte Reduction
Typical savings on complex illustration paths
DOM Sanitization
Recursive Node Pruning
Removes empty groups, comments, and defs
Recommended Best Practices
•Use 1 decimal place for simple UI icons and 2 decimal places for intricate vector illustrations.
•Always test optimized SVGs against a high-contrast background to verify curve curvature fidelity.
•Keep viewBox coordinates integer-based to simplify vector scaling operations.
Common Pitfalls & Anti-Patterns
•Rounding coordinates to 0 decimals on small 16x16 icon grids can distort delicate curved beziers.