SVG Compression: Gzip, Brotli and SVGZ Compared

By Žan Ožbot • Published • Updated • 5 min read

There are two ways to compress an SVG, and they stack. Minifying rewrites the file so it contains less. Gzip or Brotli compresses it while it travels from server to browser. Do both: minify once, then let the server compress.

Measured: SVGO, gzip and Brotli

We minified the six cover images on this blog with the settings SVGLite uses, then compressed the results with gzip level 9 and Brotli level 11. Sizes are in bytes.

Cover imageOriginalMinified+ gzip+ BrotliTotal saved
SVG vs PNG6,6403,3661,6361,41779%
File size12,4455,9692,4152,04684%
SVGO guide13,0245,9142,5992,17383%
Troubleshooting14,9447,0952,7902,33584%
Icons15,4057,4222,9812,48484%
Compression17,6188,4923,1262,60685%

Minifying alone saved 49% to 55%. Gzip alone, on the original files, saved 60% to 65%. Combining minification with Brotli saved 79% to 85%. Your results will vary; these images have more text outlines and indentation than a typical icon.

Minified or gzipped: do you need both?

Yes, when you can. Gzip hides much of the cost of whitespace and repetition, but the browser still has to parse the full file after decompressing it. Minifying also helps where gzip does not apply, such as data URIs, files bundled into JavaScript, and SVGs inlined in uncompressed HTML.

To minify, use SVGLite in the browser or follow the SVGO guide.

Check whether your server compresses SVG

curl -sI -H "Accept-Encoding: br, gzip" https://example.com/logo.svg

Look for content-encoding: br or gzip, and content-type: image/svg+xml. If the content type is wrong, compression rules often skip the file.

Enable compression

Nginx

gzip on;
gzip_vary on;
gzip_types image/svg+xml text/css application/javascript;

# with the ngx_brotli module
brotli on;
brotli_types image/svg+xml text/css application/javascript;

Apache

AddType image/svg+xml .svg

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
<IfModule mod_brotli.c>
  AddOutputFilterByType BROTLI_COMPRESS image/svg+xml
</IfModule>

CDNs and static hosts

Most CDNs compress SVG automatically. Confirm it with the curl command above.

What is SVGZ, and should you use it?

An SVGZ file is an SVG that has already been gzipped. It only displays if the server also sends Content-Encoding: gzip; without that header the browser receives bytes it cannot read. On the web, plain .svg files with server compression are simpler and can use Brotli. SVGZ is mainly useful for storing files for desktop editors that open it.

What compression cannot fix

  • Embedded bitmaps: a base64 PNG inside an SVG barely compresses. Link to it or redraw it.
  • Too many points: auto-traced artwork needs simplifying in an editor.
  • Embedded fonts: subset the font, or convert short text to paths.

These are covered in how to reduce SVG file size.

Optimize your SVG files

Drop your SVGs into SVGLite to shrink them in your browser. Nothing is uploaded.

Open the SVG optimizer

Related guides

June 3, 2023 • 10 min read
How to Reduce SVG File Size: 10 Proven Ways
Make SVG files smaller without losing quality. Ten steps covering export settings, path precision, SVGO and gzip, with measured before and after sizes.
June 5, 2025 • 8 min read
SVG vs PNG: What's the Difference and Which Is Better?
SVG stores shapes, PNG stores pixels. Compare scalability, file size, quality, printing and transparency, and see when to use each, with measured sizes.
May 15, 2023 • 6 min read
SVGO Guide: How to Optimize SVG Files
How to use SVGO from the command line, in a build, or online. Covers the default plugins, a config to copy, and the settings that break SVGs.