When inlining SVG graphics into CSS stylesheets, developers primarily choose between URL-encoded text Data URIs (data:image/svg+xml,...) and binary Base64 Data URIs (data:image/svg+xml;base64,...). Understanding how each format interacts with encoding overhead, Gzip compression, and git version control is essential for frontend performance.
1. Payload Size & Encoding Overhead
Base64 encoding translates every 3 binary bytes into 4 ASCII characters, incurring a mathematical 33% text expansion overhead on the uncompressed string.
In contrast, URL-encoded SVG retains plain XML text, encoding only reserved URI characters (such as #, <, >, "). For vector icons, URL-encoded Data URIs avoid the 33% binary expansion overhead.
2. Gzip & Brotli Compression Behavior
HTTP servers compress stylesheet assets using DEFLATE (Gzip) or Brotli dictionary algorithms.
- URL-Encoded SVG: Retains repetitive, structured XML keywords (
<path,xmlns,d=,stroke) which compress efficiently in shared stylesheet dictionaries. - Base64 Strings: High-entropy alphanumeric character strings have fewer repetitive patterns, resulting in lower compression ratios when compressed in stylesheet bundles.
3. Git Diffs & Version Control Legibility
URL-encoded SVG vectors preserve readable path coordinates in version control diffs. When an icon is updated, code reviewers can inspect coordinate and color changes directly in GitHub or GitLab pull requests, rather than reviewing an opaque Base64 string.
4. Summary Comparison Matrix
| Evaluation Criteria | URL-Encoded SVG | Base64 SVG |
|---|---|---|
| Raw String Size | Plain Text Avoids 33% Base64 expansion | +33% Overhead Binary expansion |
| Gzip/Brotli Compression | High Efficiency Structured plain XML | Lower Ratio High-entropy string |
| Git Diff Legibility | Readable Inspectable XML coordinates | Opaque Unreadable alphanumeric string |
| Dynamic Color Tinting | Supported Direct currentColor CSS masks | Manual Requires decoding to alter |
| Legacy HTML Email Support | Modern Browsers Standard RFC 3986 support | Broad Compatibility Supported by older parsers |
SVGベクターをクリーンなCSSへ瞬時に変換。
URLエンコードされたData URI、background-image、mask-image、Tailwind任意クラスをブラウザ内で直接生成。サーバーへのアップロード不要、ゼロ遅延。
Studio ワークスペースを開く