How to Reduce SVG File Size: 10 Proven Ways

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

To make an SVG smaller, export it cleanly, run it through an SVG optimizer, and serve it with gzip or Brotli. On the cover image of this article, those steps cut the file from 12,445 to 2,046 bytes (84%) with no visible change. The ten steps below are in roughly the order you would do them.

1. Export clean SVGs

Design applications like Adobe Illustrator, Sketch, or Figma often export SVGs with unnecessary baggage. Here's how to start with cleaner files:

  • Use "Export As" or "Save for Web" options instead of standard "Save As" to get more optimization options.
  • Simplify before export: Merge paths, remove unused layers, and flatten unnecessary groups in your design software.
  • Check export settings: Disable options for including unused elements, editor data, or slicing information.
  • Use appropriate precision: Most design tools let you specify decimal precision for coordinates. 1-2 decimal places is usually sufficient.

In Adobe Illustrator, use File > Export > Export As and choose SVG rather than Save As. Then:

  • Set Styling to Presentation Attributes or Inline Style
  • Set Decimal to 2 (use 3 for very small artboards)
  • Select Minify
  • Select Responsive to leave out a fixed width and height

2. Remove metadata and comments

SVG files often contain metadata that serves no purpose for web display:

<!-- Remove these elements -->
<metadata>
  <rdf:RDF>
    <cc:Work rdf:about="">
      <dc:format>image/svg+xml</dc:format>
      <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
    </cc:Work>
  </rdf:RDF>
</metadata>

<!-- And comments like these -->
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In -->

<!-- And unnecessary namespace declarations -->
<svg xmlns:x="http://ns.adobe.com/Extensibility/1.0/"
     xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/"
     xmlns:graph="http://ns.adobe.com/Graphs/1.0/">
  <!-- ... -->
</svg>

Manually removing these elements or using an optimization tool can significantly reduce file size without affecting how the SVG renders.

3. Simplify paths and reduce precision

Path data often constitutes the bulk of an SVG's size. Several techniques can reduce this:

Reduce Decimal Precision

<!-- Before: Excessive precision -->
<path d="M12.745323,34.219876 C12.745323,34.219876..."/>

<!-- After: Sufficient precision -->
<path d="M12.75,34.22 C12.75,34.22..."/>

Use Relative Commands

<!-- Before: Absolute commands -->
<path d="M10,10 L30,10 L30,30 L10,30 Z"/>

<!-- After: Relative commands -->
<path d="M10,10 l20,0 l0,20 l-20,0 z"/>

Simplify Paths

Use path simplification algorithms to reduce the number of points while maintaining visual quality. Tools like SVGO include options for this.

4. Pick the shorter of shape and path

A circle is usually shorter as a shape. A rectangle is often shorter as a path, which is why SVGO converts it:

<!-- Shorter as a circle -->
<path d="M50,10 A40,40 0 1,1 50,90 A40,40 0 1,1 50,10"/>
<circle cx="50" cy="50" r="40"/>

<!-- Shorter as a path -->
<rect x="10" y="10" width="80" height="80"/>
<path d="M10 10h80v80H10z"/>

Shapes are easier to edit by hand, so convert as the last step and keep the source file.

5. Remove redundant structure

SVG structure can often be simplified:

Remove Empty Groups

<!-- Before -->
<g>
  <g id="Layer_1">
    <circle cx="50" cy="50" r="40"/>
  </g>
</g>

<!-- After -->
<circle cx="50" cy="50" r="40"/>

Combine Similar Paths

<!-- Before -->
<path d="M10,10 L30,30" fill="none" stroke="black"/>
<path d="M40,40 L60,60" fill="none" stroke="black"/>

<!-- After -->
<path d="M10,10 L30,30 M40,40 L60,60" fill="none" stroke="black"/>

Remove Default Attributes

<!-- Before -->
<rect fill-opacity="1" stroke-opacity="1" stroke-width="1"/>

<!-- After -->
<rect/>

6. Shorten colors

Color values can be represented in various ways, with some more compact than others:

<!-- Instead of this -->
<circle fill="rgb(255, 0, 0)"/>

<!-- Use this -->
<circle fill="#f00"/>

<!-- Instead of this -->
<rect fill="#ff0000"/>

<!-- Use this -->
<rect fill="#f00"/>

For non-primary colors, use the shortest valid representation between hex, rgb, and named colors.

7. Share repeated styles

If multiple elements share the same styling, use CSS instead of repeating attributes:

<!-- Before -->
<circle fill="blue" stroke="red" stroke-width="2"/>
<rect fill="blue" stroke="red" stroke-width="2"/>
<path fill="blue" stroke="red" stroke-width="2"/>

<!-- After -->
<style>
  .common-style { fill: blue; stroke: red; stroke-width: 2; }
</style>
<circle class="common-style"/>
<rect class="common-style"/>
<path class="common-style"/>

This approach is particularly effective for SVGs with consistent styling across multiple elements.

8. Minify the code

Minification removes unnecessary whitespace, line breaks, and indentation:

<!-- Before -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
  <circle
    cx="50"
    cy="50"
    r="40"
    fill="red"
  />
</svg>

<!-- After -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="red"/></svg>

This does not affect rendering. The saving depends on how heavily the file was indented.

9. Automate it with SVGO

SVGO (SVG Optimizer) is a powerful Node.js-based tool that applies many of the strategies mentioned above automatically. It can be used:

  • As a command-line tool
  • As a Node.js module in build processes
  • Through online interfaces like SVGLite
  • Via plugins for design tools

SVGO applies dozens of optimization plugins, each targeting specific aspects of SVG files. It roughly halved all six cover images on this blog.

10. Compress with gzip or Brotli

As a final step, ensure your web server compresses SVG files with GZIP or Brotli:

# Apache .htaccess
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>

# Nginx
gzip on;
gzip_types image/svg+xml;

SVG is text, so it compresses well. On our minified cover images, gzip saved a further 51% to 63%.

Measured results

These are the sizes for the cover image at the top of this article, minified with the same settings SVGLite uses:

StageFile sizeSaved
Original12,445 B-
Gzip only4,503 B64%
Minified with SVGO5,969 B52%
Minified + gzip2,415 B81%
Minified + Brotli2,046 B84%

The minified file rendered pixel-for-pixel the same as the original in our test.

Common questions

Why is my SVG file so big?

Usually an embedded bitmap, too many path points from auto-tracing, or editor metadata. Open the file in a text editor: a long "data:image" string means a bitmap is embedded.

Does changing the width and height make an SVG smaller?

No. Width and height change the display size. The file size depends on how much the SVG contains.

Does reducing SVG file size lose quality?

Removing metadata and redundant code does not. Lowering precision or simplifying paths can, so compare the result with the original at a large size.

Next: configure it yourself with the SVGO guide, or see gzip and Brotli compared.

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 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.
June 2, 2023 • 5 min read
SVG Compression: Gzip, Brotli and SVGZ Compared
How much do gzip and Brotli shrink an SVG? Measured results for six files, server config for Nginx and Apache, and when SVGZ is worth using.