Image Formats Explained: JPEG, PNG, WebP, AVIF

Picking the right image format is one of the highest-leverage performance decisions you can make. The wrong format wastes bandwidth, slows pages, and degrades visual quality. This guide compares the major web image formats and gives you a decision framework.

Format Comparison

FormatTypeTransparencyBest forNotes
JPEGLossy bitmapNoPhotographsUniversal support; tunable quality
PNGLossless bitmapYesScreenshots, icons, line artLarger files; perfect for sharp edges
WebPLossy or losslessYesMost web images25-35% smaller than JPEG/PNG
AVIFLossy or losslessYesHero images, large assets~50% smaller than JPEG
SVGVector XMLYesLogos, icons, illustrationsInfinite scale; CSS-stylable
GIFLossless animation1-bitLegacy onlyMP4/WebM almost always better

The Decision Framework

  1. Is it a logo, icon, or geometric illustration? → SVG.
  2. Does it need to be a small animation? → MP4 or WebM, not GIF.
  3. Is it a photograph or photographic asset? → AVIF primary, WebP fallback, JPEG for legacy.
  4. Does it need transparency or pixel-perfect edges (screenshots, UI assets)? → WebP lossless primary, PNG fallback.
  5. Is it a complex composite that needs both? → Use <picture> with AVIF → WebP → JPEG/PNG fallback.

The <picture> Pattern

<picture>
  <source srcset="hero.avif" type="image/avif">
  <source srcset="hero.webp" type="image/webp">
  <img src="hero.jpg" alt="..." width="1600" height="900" loading="lazy">
</picture>

Browsers pick the first supported format. Always include the img as the last child — it's the universal fallback and the element actually rendered.

Typical Savings

  • JPEG → WebP: 25-35% smaller at same visual quality.
  • JPEG → AVIF: 40-55% smaller at same visual quality.
  • PNG → WebP lossless: 25% smaller.
  • GIF animation → MP4: 80-95% smaller.

Getting Compression Quality Right

Format choice sets the ceiling; the quality setting decides where you land under it. A few rules that hold up in practice:

  • Photos (lossy): quality 75–85 is the sweet spot for JPEG and WebP — visually indistinguishable from the original at a fraction of the size. Below ~60 you start seeing blocky artefacts and smeared detail.
  • AVIF holds up lower: quality 50–60 often matches JPEG 80, so push it harder than you would a JPEG.
  • Flat graphics, screenshots, text: use lossless (PNG or WebP-lossless). Lossy compression turns sharp edges and coloured text into visible halos.
  • Resize before you compress. Serving a 4000px image into an 800px slot wastes far more bytes than any quality tweak — match pixel dimensions to the display size first.
  • Always set explicit width and height to reserve layout space, and add loading="lazy" to below-the-fold images.

Try It Yourself

Resize and crop images for web with DesignKit's image tools.

Image Resizer →

Frequently Asked Questions

JPEG suits photographs and smooth tonal gradients, where its lossy compression saves a lot with no visible difference. PNG suits screenshots, icons, line art and anything with hard edges or transparency, where lossless keeps text and edges crisp. Quick test: smooth tonal variation → JPEG; flat colour with sharp edges → PNG.
Yes — universal support and 25-35% smaller than JPEG/PNG. Serve with JPEG/PNG fallback via <picture>.
Newest format; ~50% smaller than JPEG. Now widely supported. Use for hero images with WebP/JPEG fallback.
Always for logos, icons, illustrations. Infinite scale; not for photos.
Rarely, for animation. An MP4 or WebM is typically 5–10 times smaller than the same GIF and supports far more colours, so use video for anything moving. GIF only still makes sense for tiny, simple loops where broad autoplay-video support is a concern.