WebP vs AVIF: a practical comparison
Published: · Nooknear
When you set out to shrink a site’s images, the first question is usually WebP vs AVIF. Both produce smaller files than JPEG and PNG, and both work in modern browsers. But they don’t do the job the same way. This post compares WebP and AVIF on the criteria that matter in production and explains when to reach for each.
The short answer
- Use WebP as your default. Support is close to universal, encoding is fast and results are predictable.
- Add AVIF as an extra option for large, photo-heavy images. At the same visual quality it usually yields a smaller file, and the difference shows most on the biggest image on the page.
- Keep JPEG as a fallback, but only where you genuinely need it: email clients, some social media APIs, legacy integrations.
Now for the details.
Where the formats come from
WebP was announced by Google in 2010 and is based on the intra-frame compression of the VP8 video codec. It supports lossy and lossless compression, transparency (alpha) and animation, so on its own it can replace JPEG, PNG and GIF.
AVIF is an image format derived from the AV1 video codec, developed by the Alliance for Open Media. It uses newer compression techniques and supports wide color gamut, HDR and higher bit depths. The cost is slower encoding and a slightly more complex toolchain.
File size and visual quality
The general trend is clear: at the same perceived quality, AVIF usually produces smaller files than WebP, and WebP produces smaller files than JPEG. But “how much smaller” has no single answer. Results vary a lot depending on:
- The kind of image. On photos with smooth gradients (skies, skin, food), AVIF’s advantage is obvious. At low quality settings, where JPEG gets blocky and WebP gets blurry, AVIF holds a cleaner image.
- The quality setting. At very high (near-lossless) quality the gap narrows. It’s widest in the medium and low quality range.
- Fine detail. With sharp text, screenshots and thin lines, AVIF can smooth away detail at low quality. For these, lossless WebP or PNG is often the better choice.
The best approach is to test with your own images. Pick a few typical ones, tune quality in each format until they look the same to your eye, and compare file sizes. Our free browser tools are made for this: PNG to WebP and JPG to AVIF. Both run entirely in your browser without uploading your files.
Browser support
WebP is supported in every current browser: Chrome, Edge, Firefox, Opera and Safari (from macOS Big Sur and iOS 14). The share of browsers without support is now negligible in practice; unless you have users stuck on very old iOS versions, you can ship WebP as your only format.
AVIF is now in every major browser engine too: Chrome and Edge, Firefox, and Safari 16 and later. Still, support is more recent than WebP’s, so devices that haven’t been updated and some in-app browsers can lag behind. That’s why it’s still wise to serve AVIF with a fallback rather than on its own.
The simplest way is the <picture> element. The browser picks the first source it supports:
<picture>
<source type="image/avif" srcset="cover-800.avif 800w, cover-1200.avif 1200w" sizes="100vw">
<source type="image/webp" srcset="cover-800.webp 800w, cover-1200.webp 1200w" sizes="100vw">
<img src="cover-800.jpg" width="1200" height="800" alt="Breakfast plate">
</picture>
You can also do this on the server by looking at the Accept header: if the browser advertises image/avif, return AVIF, otherwise WebP. If you do, add Vary: Accept to the response, or your CDN may cache the wrong format.
Encoding speed
This is the biggest practical difference. AVIF encoding is noticeably slower than WebP and uses more CPU. As you lower the encoder’s speed setting (slower, more efficient), files get smaller but encode time grows quickly. Decoding AVIF is a bit heavier too, though on modern devices that’s rarely noticeable on a typical page.
What this means depends on when you generate images:
- At upload time, in the background (in a queue, with no user waiting), AVIF’s slowness is usually fine. You encode once and serve thousands of times.
- At request time, on the fly, the first visitor waits for the encode. Fast encoder settings and a good cache are essential here.
- In the user’s browser (for example, resizing before upload), WebP is far easier. Browsers can produce WebP with
canvas.toBlob('image/webp'); AVIF usually needs a WebAssembly encoder.
Which one when?
| Situation | Recommendation |
|---|---|
| General site images, product photos | WebP |
| The largest image on the page (hero, cover) | AVIF with a WebP fallback |
| Screenshots, graphics with text | Lossless WebP or PNG |
| Logos and icons | SVG; otherwise lossless WebP |
| Product images with transparency | WebP (supports alpha) |
| Animation | Animated WebP if short; video (MP4/WebM) if longer |
| Email, legacy integrations, some social media APIs | JPEG |
That last row matters. The Instagram Graph API, for example, doesn’t accept WebP in image_url. Even if you use modern formats everywhere else, you may need a JPEG fallback wherever you hand images to outside systems.
A few traps to avoid
Color profiles. If you convert wide-gamut (Display P3) photos and lose the profile, colors can look washed out. Converting to sRGB for the web is the safe path.
EXIF orientation. Phone photos often store orientation in EXIF. If you strip metadata during conversion without applying the orientation first, images show up sideways.
Treating quality numbers as equal across formats. “80” in WebP is not the same quality as “80” in AVIF. Set each format’s quality separately, by eye or with a perceptual metric such as SSIM or Butteraugli.
Very small images. On a 150-pixel thumbnail, the byte difference between formats shrinks to a few hundred bytes. AVIF’s extra complexity usually isn’t worth it there.
Where Nooknear stands today
For every image you upload to Nooknear, four WebP variants (thumb, small, medium, large) are generated automatically today, plus an optional full-size JPEG variant for places that don’t accept WebP. AVIF output and automatic format selection based on the browser’s Accept header are on our roadmap but not available yet. So if you want to serve AVIF today, you’ll need to convert on your side.
Conclusion
WebP is the right default for most sites today: broad support, fast encoding and clear savings over JPEG and PNG. AVIF takes you a step further, especially on large photos, but comes with slower encoding and the need for a fallback. The best approach is to treat them as layers rather than rivals: WebP first, AVIF where it pays off, JPEG where it’s required.
To compare formats with your own images, try the PNG to WebP and JPG to AVIF tools. If you’d rather have WebP variants generated and served from a CDN for you, take a look at our quickstart.