Web development

SVG, PNG, WebP, AVIF or ICO: which icon format to use in each case

The real differences between SVG, PNG, WebP, AVIF, ICO and PDF for icons: which scale without loss, how much they weigh, where each is supported and how to convert.

For an icon on a website, the default format is SVG: it is vector-based, scales without losing sharpness, weighs a few hundred bytes, can be coloured with CSS and animated. Bitmap formats (PNG, WebP, AVIF) only make sense when the destination does not accept SVG or when the “icon” is really an image with photography or complex gradients. ICO survives for one reason only, the favicon.ico that old browsers and search engines look for, and PDF shows up when the icon is going to be printed or placed in documents.

This article compares the six formats with concrete figures, explains where each is supported and how to convert between them without installing anything.

The six formats at a glance

Format Type Scales without loss Transparency Colour editable with CSS What it is for
SVG Vector (XML) Yes Yes Yes (currentColor, fill, stroke) Interface icons, logos, flat illustrations
PNG Lossless bitmap No Yes (8-bit) No When the destination requires a bitmap: apple-touch-icon, manifest, apps, emails
WebP Bitmap (lossy or lossless) No Yes No Rasterised images and icons on the web, lighter than PNG
AVIF Bitmap (lossy or lossless) No Yes No Like WebP but more compact; newer support
ICO Container of several PNG/BMP No (several sizes inside) Yes No Exclusively favicon.ico
PDF Vector document Yes Yes No Print, documents, inserting into Office or editorial design

How much each one weighs

The same icon (Lucide’s arrow-right, 24 × 24, 2 px stroke) converted to each format:

Format Output size Weight
SVG any 0.34 KB (0.27 KB minified)
PNG 64 × 64 px 0.31 KB
PNG 512 × 512 px 3.2 KB
WebP (lossless) 512 × 512 px 0.76 KB
AVIF (quality 80) 512 × 512 px 1.75 KB
ICO (16, 32 and 48 px) three sizes 0.65 KB

The lesson is not the exact number (it depends on the icon and the encoder) but the scale: an SVG line icon weighs the same as its 64 px PNG and works at any size, while the PNG grows tenfold at 512 px. Two more details: for flat artwork, lossless WebP beats AVIF (which is designed for photography), and bitmaps need one version per screen density (1x, 2x, 3x) to look sharp.

When to use each format

SVG: whenever you can

  • Interface icons: inline (<svg> in the HTML), as a sprite or as a component. It allows fill="currentColor" to inherit the text colour and change it on :hover or in dark mode.
  • Logos and brands: sharp on any screen and in print.
  • As <img src="icon.svg">: it works, but the SVG becomes an opaque image: it cannot be coloured with CSS or animated from outside (internal animations do run), and scripts inside the file do not execute.

One caution: an SVG exported from a design tool may carry metadata, empty layers and endless decimals. Run it through an optimiser (SVGO) or download it already clean from a library.

PNG: when the destination demands it

  • apple-touch-icon.png (180 px) and the manifest icons (192 and 512 px): iOS and Android require PNG.
  • Native app icons (iOS, Android, macOS, Windows).
  • HTML emails: many clients do not render SVG.
  • Sites that do not allow SVG uploads (some CMSs block it for security, because an SVG can contain scripts).

WebP and AVIF: rasterised icons on the web

If for some reason you need an icon as a bitmap inside a page (a photographic icon, a screenshot, an icon with complex shadows), WebP and AVIF weigh considerably less than PNG at the same quality. WebP support is universal in current browsers; AVIF is supported by Chrome, Firefox and Safari from version 16, but it is wise to offer a <picture> with a WebP or PNG fallback. For ordinary interface icons, however, neither replaces SVG.

ICO: only for favicon.ico

ICO is a container that bundles several sizes (usually 16, 32 and 48 px) in one file. Today a favicon.svg covers modern browsers, but favicon.ico is still needed for old browsers and for search engines that request it by convention at the domain root; Google also requires the icon to be a multiple of 48 px or an SVG to show it in results. Do not use ICO for anything else.

PDF: print and documents

A vector PDF keeps its sharpness in print and can be placed in Word, PowerPoint, InDesign or Keynote without converting. If you export an icon to PDF for a document, check that it keeps transparency; not every converter does.

How to convert between formats

  • From SVG to PNG, WebP, AVIF, ICO or PDF: with sharp in Node.js (sharp('icon.svg').resize(512).png()), with Inkscape or ImageMagick in the terminal, or in the browser with the AIMRAN Icons converter, which exports to all six formats (AVIF only if the browser can encode it) without uploading the file to any server.
  • From PNG to SVG: there is no exact conversion, because a bitmap has no paths. What tools do is vectorise (trace outlines around areas of colour), and the result is only good with flat icons of few colours. The AIMRAN Icons converter uses imagetracerjs for this; if the original is a logo with gradients, it is better to ask whoever designed it for the vector file.
  • From SVG to a React or Vue component: the same converter generates the component with the props passed through to the <svg>, which avoids copying the XML by hand. In large projects, SVGR does the same at build time.

Common mistakes

  1. Serving a 24 px PNG and scaling it up: it looks blurry on high-density screens. Use SVG or, at the very least, a PNG at twice the size.
  2. Embedding an SVG with <img> and then trying to colour it with CSS: it does not work; for that the SVG must be inline or a sprite.
  3. Exporting line icons with the stroke converted to fill “just in case”: you lose the ability to change the stroke width and, in some sets, the icon stops aligning with the rest.
  4. Using ICO as the home-screen icon: iOS and Android ignore it; they need PNG.
  5. Mixing sets: a Material icon (filled, 20 px grid) next to a Lucide one (2 px line, 24 px) shows. Pick one set and stick to it; AIMRAN Icons shows the set and licence of every icon so it is easy to check.

Conclusion

SVG for everything that is interface, logos and vectors; PNG only where the destination does not accept SVG (app icons, home screen, email); WebP or AVIF if the icon is really a bitmap; ICO exclusively for favicon.ico; PDF for print and documents. And if you have to convert, go from vector to bitmap, never the other way round if you can avoid it.

Sources and references

  1. MDN: Image file type and format guide developer.mozilla.org
  2. MDN: SVG as an image developer.mozilla.org
  3. Can I use: AVIF image format caniuse.com
  4. Can I use: WebP image format caniuse.com
  5. Google Search Central: Define a favicon to show in search results developers.google.com
  6. AIMRAN Icons: icon search and converter icons.aimran.es

Related tools

Herramientas gratuitas de AIMRAN Tools que funcionan en tu navegador, sin registro.

Ver todas las herramientas
  • Icon converter (SVG, PNG, React)

    Converts PNG to SVG (vectorised), SVG to PNG, JPG, WebP, AVIF, ICO or PDF, and SVG to a React or Vue component, in the browser.

  • AIMRAN Icons: icon search

    Over 360,000 freely licensed icons from 222 sets, searchable in Spanish, English, French and German; download as SVG, PNG, WebP, AVIF, ICO or PDF.

Web development

How to convert images to WebP (and when not to)

What WebP is, how much it saves over JPEG and PNG, how to convert images in the browser, the terminal or Node.js, and how to serve them with picture.

4 min read