Skip to content
Tutorials

Image Formats for the Web: AVIF, WebP, JPEG, PNG and JPEG XL Compared

AIDToolStack EditorialNovember 7, 20268 min read
ImagesWeb PerformanceAVIFWebPJPEG XL
Share:Twitter

Someone exports a product photo from a design tool as a PNG, because PNG is "the high-quality one", and the homepage hero ends up several times heavier than it needs to be. Someone else runs every screenshot in the docs through lossy JPEG, and the code in them grows coloured fringes. Both are format mistakes, and both are easy to avoid once you know what each format is for.

This is a practical guide to the five raster formats you'll meet on the web in November 2026: what browsers support, what each format is good at, how to serve more than one, and which encoder settings actually matter. SVG gets a mention for icons, but it has its own post.

Browser support as of November 2026

The figures below come from MDN's image format guide (last modified 5 November 2026) and Can I Use for AVIF, WebP and JPEG XL. "Global" is Can I Use's estimate of users on a supporting browser.

FormatChromeEdgeFirefoxSafari (macOS)Safari (iOS)Global
JPEG, PNGallallallallallall
WebP32186516.0 (partial 14 to 15.6)1497.32%
AVIF851219316.4 (partial 16.1 to 16.3)16.096.71%
JPEG XL155not yet158partial from 17partial from 1769.25%

The JPEG XL row is the one that changed this year. Can I Use lists Chrome 155 and Firefox 158 as the first versions with it on by default (earlier versions had it behind a flag or setting), and Safari as partial since 17. MDN notes that "Safari does not support progressive download of JPEG XL files". Edge has no supported version listed yet. With roughly 30% of users unable to decode it, JPEG XL is a <picture> candidate with a fallback, not something you can ship bare.

AVIF and WebP are now safe as the main format for most audiences, though MDN still recommends a fallback in a <picture> element, and so would I if you serve old iPhones or embedded browsers.

What each format is good at

From the same MDN guide:

JPEGPNGWebPAVIFJPEG XL
Lossyyesnoyesyesyes
Losslessnoyesyesyesyes
Alpha channelnoyesyesyesyes
Animationnovia APNGyesyesyes
Bit depth, HDR8-bit1 to 16-bit per channel8-bitHDR and wide gamutHDR and wide gamut
Max dimensions65,535 px2,147,483,647 px16,383 px2,147,483,647 px1,073,741,823 px

A few rows deserve a sentence each.

JPEG has no alpha. If you convert a transparent PNG to JPEG, something has to fill the transparent pixels. Our image compressor fills them with white when you pick JPEG output, which is the sensible default, but it means a logo on a dark site will get a white box.

AVIF doesn't render progressively. MDN: "files must be fully downloaded before they can be displayed." For a large hero image on a slow connection, that means a blank box until the last byte arrives. That's a real trade-off for your Largest Contentful Paint, and it's one reason JPEG XL gets attention: MDN says most browsers can render it progressively.

WebP tops out at 16,383 pixels a side. Rarely a problem for photos, occasionally a problem for very long screenshots or sprite sheets.

Lossy compression ruins sharp edges. MDN's advice is blunt: for "screenshots, diagrams, logos, and line art, prefer lossless encoding, as blurring and colored fringes around text and sharp edges are very visible." Lossless WebP or PNG for those; lossy for photographs.

Picking a format

Decision tree: vector artwork goes to SVG; photographs to AVIF or WebP with a JPEG fallback; screenshots and line art to lossless WebP or PNG; transparency rules out JPEG; animation goes to animated AVIF or WebP rather than GIF
Decision tree: vector artwork goes to SVG; photographs to AVIF or WebP with a JPEG fallback; screenshots and line art to lossless WebP or PNG; transparency rules out JPEG; animation goes to animated AVIF or WebP rather than GIF

The short version I'd use on most projects:

  1. Icons, logos, diagrams drawn as shapes: SVG. MDN says to "prioritize the SVG version whenever possible" for icons.
  2. Photographs: AVIF first, WebP second, JPEG as the fallback.
  3. Screenshots, UI captures, text-heavy images: lossless WebP, with PNG as the fallback.
  4. Anything with transparency: WebP or AVIF, with PNG as the fallback. Never JPEG.
  5. Animations: animated WebP or AVIF, or a muted <video>. MDN warns that converting full-colour images to GIF can produce "unsatisfactory dithering".
  6. Very large, high-resolution photos where progressive display matters: consider JPEG XL inside <picture>, with AVIF or JPEG behind it.

Serving more than one format

There are two ways to let each browser get the best format it can decode.

<picture> with type. The browser walks the <source> elements in order and uses the first one whose type it supports, falling back to the <img>:

<picture>
  <source type="image/avif" srcset="/img/product-1200.avif">
  <source type="image/webp" srcset="/img/product-1200.webp">
  <img src="/img/product-1200.jpg" alt="Walnut desk shelf, front view"
       width="1200" height="800">
</picture>

Put the width, height and alt on the <img>; it's the element that actually renders. Each <source> can also carry its own srcset and sizes when you have several widths per format; the next/image guide shows how sizes shapes the generated srcset.

Content negotiation. An image CDN or optimizer reads the request's Accept header and returns the best match from one URL. Next.js's <Image> does this: per the Next.js image docs, formats defaults to ['image/webp'], AVIF is opt-in with formats: ['image/avif', 'image/webp'], the first match in the array wins, and each format is cached separately, which the docs warn increases storage. If you'd rather skip the optimizer, the image compressor is a quick way to produce static WebP files by hand.

Encoders and the settings that matter

Quality numbers are not portable between encoders. sharp's defaults alone show it: quality 80 for JPEG and WebP, 50 for AVIF. Pick a quality per format by looking at your own images, not by copying a number from another tool.

sharp (Node.js). The sharp output docs list the defaults: jpeg quality 80 with mozjpeg: false; webp quality 80, effort 4; avif quality 50, effort 4, chroma subsampling 4:4:4; png compression level 6. JPEG XL output needs libvips built with libjxl, which the prebuilt binaries don't include, and the docs call it experimental. A build script that writes all three common formats:

import sharp from "sharp";

const input = sharp("hero.png");
await Promise.all([
  input.clone().avif({ quality: 50, effort: 6 }).toFile("hero.avif"),
  input.clone().webp({ quality: 78 }).toFile("hero.webp"),
  input.clone().jpeg({ quality: 80, mozjpeg: true }).toFile("hero.jpg"),
]);

effort buys a smaller file with CPU time, the same trade the cwebp docs describe for -m below. Fine in a build step, painful on every request.

cwebp. From the cwebp docs: -q runs 0 to 100 and defaults to 75; -m (method) runs 0 to 6, default 4, higher is slower and smaller; -lossless and -near_lossless handle screenshots; -sharp_yuv gives a sharper RGB-to-YUV conversion at some speed cost, worth trying on images with fine coloured detail. -metadata defaults to none, so EXIF (including GPS location from phone photos) is dropped unless you ask for it.

cwebp -q 78 -m 6 -sharp_yuv photo.jpg -o photo.webp
cwebp -lossless screenshot.png -o screenshot.webp

avifenc (libavif). Per the avifenc manual: -q is colour quality 0 to 100, where 100 is lossless; --qalpha does the same for the alpha channel; -s is speed 0 (slowest) to 10 (fastest), default 6; -d sets 8, 10 or 12-bit output.

avifenc -q 60 -s 4 photo.png photo.avif

jpegli. If you still need JPEG, Google's jpegli is a JPEG encoder and decoder that is "API and ABI compatible with libjpeg62", so it can replace the system libjpeg, and it ships a cjpegli command-line tool. The output is ordinary JPEG that every browser decodes. MozJPEG is the other well-known improved JPEG encoder; sharp exposes it through the mozjpeg: true option.

Compression claims, and where they come from

You'll see percentages everywhere. The ones worth quoting have a named source. Google's WebP page says "WebP lossless images are 26% smaller in size compared to PNGs" and "WebP lossy images are 25-34% smaller than comparable JPEG images at equivalent SSIM quality index", citing its own studies. That's the format's author measuring on its own test set. Your photos, your quality target and your encoder settings will give different numbers, so measure a representative sample before committing a whole media library to a conversion.

Converting in the browser with our tools

Our image compressor and PNG to WebP converter run in your browser using the Canvas API, so files aren't uploaded. The compressor outputs JPEG, WebP or PNG with a quality slider and optional maximum dimensions; the batch image converter does the same for many files at once. None of them encode AVIF; use sharp or avifenc for that.

One caveat that applies to every canvas-based converter, ours included: per MDN's toBlob reference, browsers are only required to support PNG output, and if the requested type isn't supported "the data will be exported as image/png". If a WebP file from a browser tool is suspiciously large, check what it actually is before you ship it.

Gotchas before you convert a whole library

  • Keep the originals. Re-encoding a lossy file adds a second round of artefacts.
  • Strip metadata on purpose, not by accident. Dropping EXIF saves bytes and removes location data, but check that colours still look right on a wide-gamut screen afterwards.
  • Don't lossy-encode screenshots of code or UI. Use lossless WebP or PNG.
  • Check transparency after conversion. A JPEG fallback for a transparent image needs a background colour that matches where it's displayed.
  • Watch the 16,383 px WebP limit on long screenshots.
  • Set width and height on every <img>, whatever the format, so the layout doesn't jump while it loads.
AE

Written by AIDToolStack Editorial

Researched from official documentation, specifications and vendor pages, listed under Sources below. Last checked November 2026.

Sources

  1. developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types
  2. caniuse.com/avif
  3. caniuse.com/webp
  4. caniuse.com/jpegxl
  5. nextjs.org/docs/app/api-reference/components/image
  6. sharp.pixelplumbing.com/api-output/
  7. developers.google.com/speed/webp/docs/cwebp
  8. github.com/AOMediaCodec/libavif/blob/main/doc/avifenc.1.md
  9. github.com/google/jpegli
  10. developers.google.com/speed/webp
  11. developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob

Related Posts

Explore on AIDToolStack

Discover tools and servers featured in our directory.

MCP Servers

Trigger.dev Jobs MCP ServerManage Trigger.dev background jobs from your AI coding assistant. Monitor job runs, trigger tasks manually, inspect execution logs, manage schedules, and debug failed runs. The server provides operational visibility into your background job infrastructure — see which tasks are running, queued, or failed, and take action. Your AI can help diagnose job failures from execution logs, retry failed tasks, and optimize concurrency configurations for better throughput.Tailscale Network MCP ServerManage your Tailscale mesh VPN network from your AI coding assistant. View connected devices, manage ACLs, configure exit nodes, check device status, and manage DNS settings. The server provides visibility into your Tailscale network — see which machines are online, troubleshoot connectivity issues, manage network access policies, and configure routes. Useful for developers managing distributed infrastructure where Tailscale provides secure networking between services.Portainer Docker MCP ServerManage Docker environments through Portainer's API from your AI coding assistant. Control containers, images, networks, and volumes across multiple Docker hosts and Kubernetes clusters. The server provides tools for container lifecycle management, image pulling and building, stack deployment, and resource monitoring. Portainer's multi-environment management makes this server particularly valuable for teams managing containers across development, staging, and production environments.

Reviews

Sign in to leave a review.

No reviews yet. Be the first!

Comments

Sign in to leave a comment.

No comments yet. Be the first!

Sponsor Our Newsletter

Reach thousands of developers who are actively evaluating AI tools, MCP servers, and dev infrastructure. Our weekly newsletter goes to engaged technical decision-makers.

Growing subscriber baseHigh open rates

All sponsored content is clearly labeled per our editorial policy.