Format · SVG

Vectors don't
have pixels to lose

SVG describes shapes in XML. That changes what "compression" can even mean: there is no quantisation step, no quality dial, and no pixels to approximate — only text to shorten and bytes to gzip.

XML · Vector · Resolution independent · Gzip
∞ scales without loss3× typical gzip0 quality dials
Model

Geometry, not samples

A raster image is a grid of samples. An SVG is a list of instructions — paths, shapes, transforms, colours — that a renderer executes at whatever resolution it needs.

Reference

What that changes

A logo exported as SVG stays sharp at any size because there is nothing to resample. The same logo exported as a 2000px PNG carries 2000 pixels of detail even when displayed at 32px, which is why icons are the most wasteful thing on most sites.

It also means SVG files can be tiny for simple artwork — a few hundred bytes for a chevron — and surprisingly large for complex ones. A traced photograph, a detailed map or an illustration with thousands of paths can exceed the PNG it replaced, because each path carries coordinates at full precision.

Text is the payload

SVG is markup, so the file is dominated by repeated attribute names, redundant whitespace and coordinates with more decimal places than any display can use. Optimisation is therefore a text problem, not a signal-processing one.

Optimise

What is safe to remove

Minification is lossless if it only removes redundancy. Everything beyond that is a visual decision.

Safe: text redundancy

Whitespace, comments, editor metadata, unused namespace declarations and default attribute values can all go without changing a single rendered pixel.

Safe: precision reduction

Coordinates at 15 decimals are absurd for any display. Rounding to two or three is invisible and can halve the file.

Careful: path simplification

Merging or smoothing paths changes geometry. At icon size it is invisible; at billboard size it is not. Decide per use.

Careful: converting shapes to paths

Flattening rectangles and strokes into paths can help or hurt depending on the renderer. Measure before assuming.

Gzip or Brotli on the wire is where SVG compression actually happens — often a 3× reduction before any minification.

Tradeoffs

When an SVG is the wrong answer

Vectors are not universally better. Four cases where a raster format wins outright.

Photographs Traced photographic SVG is enormous and looks wrong. Use JPEG, WebP or AVIF.
Complex illustrations with texture Thousands of paths cost more than a well-compressed raster.
Anything with effect filters Blurs and shadows are expensive to render and inconsistently supported.
Untrusted input SVG can carry script. Treat uploaded SVG as executable content, not as an image.
Context

Where it fits in a delivery pipeline

SVG belongs to the interface layer, not the photographic one.

Icons, logos, diagrams and simple illustrations should ship as SVG: they are resolution-independent and usually smaller than the PNG they replace. Everything captured by a camera belongs in a raster format, and the choice among those is covered in image formats compared. For the raster side of the same page, see the compression guide.

FAQ

SVG — FAQ

Is SVG lossless?

SVG has no pixels to lose. Minification is lossless if it only removes redundancy; path simplification is not.

Why is my SVG bigger than my PNG?

Too many paths, embedded raster images, or full-precision coordinates. SVGs that contain a bitmap are the usual culprit.

Does gzip really help?

Substantially — SVG is text with repeated attribute names, which compresses well. Serve it compressed and the on-wire size drops sharply.

Can I convert SVG to PNG?

Yes, at a chosen resolution. That is a rendering step, and the result is a raster you then have to size deliberately.

Is SVG safe to accept from users?

Not without sanitising. SVG can contain script and external references; treat it as code.

Rasters handled; vectors stay vectors.
Compressy works on JPG, PNG, WebP and AVIF — minify SVG with a dedicated tool, and keep it out of the raster path.