Image Formats Explained: JPEG, PNG, WebP, AVIF & GIF — How to Choose

JPEG for photos, PNG for screenshots, WebP and AVIF for the modern web, GIF for tiny animations — and why picking wrong costs you megabytes and quality. A complete guide to choosing with confidence.

📂 Images & Design ⏱ About 12 minutes 📶 Beginner 🛠️ Pairs with: Image Converter

What you will learn

  • Explain lossy vs lossless compression in one sentence each
  • Know what JPEG, PNG, WebP, AVIF and GIF are each best at
  • Choose the right format for photos, logos, screenshots and animations
  • Use modern formats with a fallback for older browsers
  • Avoid the format mistakes that bloat pages and blur text
In this guide
  1. First, the two ideas that decide everything
  2. JPEG: the photograph format
  3. PNG: the pixel-perfect format
  4. WebP and AVIF: the modern web formats
  5. GIF: the 256-colour survivor
  6. How to choose: the decision table
  7. Common mistakes
  8. Try it: Image Converter
  9. Frequently asked questions

First, the two ideas that decide everything

Every image format is an answer to two questions: what may be thrown away, and what must be kept?

Lossy compression (JPEG, lossy WebP/AVIF) throws away detail the eye barely notices — subtle colour variations, fine high-frequency texture — and gets dramatically smaller files in return. Open and re-save a JPEG ten times and it visibly degrades, because each save throws away a little more. Lossless compression (PNG, lossless WebP/AVIF) keeps every pixel exactly, at the cost of bigger files. Re-save a PNG a hundred times and it is bit-for-bit identical.

The second question is what the format can express: transparency (a see-through background), animation (many frames), and colour depth. No single format does everything — which is why we have five of them.

FormatCompressionTransparencyAnimationBest for
JPEGLossyNoNoPhotos, complex images
PNGLosslessYesNo (APNG exists)Logos, screenshots, text, graphics
WebPLossy or losslessYesYesWeb photos & graphics
AVIFLossy or losslessYesYesSmallest files on the modern web
GIFLossless, 256 coloursYes (1-bit)YesTiny simple animations

JPEG: the photograph format

JPEG (1992) was designed for photographs, and it shows. It converts the image to a frequency representation (DCT) and discards the high-frequency detail our eyes are least sensitive to — smooth gradients and skin tones survive beautifully, because photos rarely have razor-sharp edges. The quality setting (typically 70–85 for the web) is a dial for how much to discard: quality 85 is usually indistinguishable from the original at a third of the size, while quality 50 starts to show blocky artefacts in skies and shadows.

JPEG's weaknesses are exactly where photos end: it has no transparency, and its artefacts smear sharp edges — text, line art and logos come out fuzzy with ringing halos. A screenshot saved as JPEG is both bigger and uglier than the same screenshot as PNG.

PNG: the pixel-perfect format

PNG (1996) is lossless and supports full alpha transparency — every pixel can be partly see-through. That makes it the format for logos, icons, screenshots, diagrams and anything with text. It compresses flat areas of solid colour brilliantly (a screenshot of a settings window can shrink 10×) and photographs terribly (a 12 MP photo as PNG can be 20 MB, because noise doesn't compress).

Rule of thumb: if the image has sharp edges or needs transparency, PNG; if it's a photo, almost never PNG.

WebP and AVIF: the modern web formats

WebP (Google, 2010) does both jobs: lossy mode typically beats JPEG by 25–35% at the same quality, and lossless mode beats PNG by ~25%. It supports transparency and animation, and every modern browser reads it. For most web work today, WebP is the default sensible choice.

AVIF (2019, based on the AV1 video codec) goes further — often 50% smaller than JPEG at the same quality, with better detail in the bargain. The cost is encoding time (slower to produce) and slightly narrower support in very old browsers. For hero images and large photos where every kilobyte counts, AVIF is the current champion.

The practical approach is progressive: serve AVIF first, WebP second, JPEG as the fallback, using the <picture> element so the browser picks the first format it understands:

<picture>
  <source srcset="hero.avif" type="image/avif">
  <source srcset="hero.webp" type="image/webp">
  <img src="hero.jpg" alt="Sunset over the harbour">
</picture>

GIF: the 256-colour survivor

GIF (1987) holds at most 256 colours per frame, which makes it a poor format for photos — skies band into stripes. But it has two tricks no older format had: simple animation, and 1-bit transparency (a pixel is either fully transparent or fully opaque — no soft edges). It survives today almost entirely for short, silent, looping animations: reaction GIFs, tiny demos, loading spinners. For anything longer than a few seconds, a muted looping video (<video> or WebP/AVIF animation) is a fraction of the size.

How to choose: the decision table

Use caseChooseWhy
Photograph on a websiteAVIF, else WebP, JPEG fallbackSmallest file at good quality
Logo / icon with transparencyPNG or SVG (vector)Sharp edges, real transparency
Screenshot or diagramPNG (or WebP lossless)Text stays crisp
Short looping animationWebP / AVIF animation, or videoGIF is 5–10× bigger
Photo you will edit againPNG, TIFF or RAWNever re-save a JPEG as a master
Maximum compatibilityJPEG / PNGReadable everywhere since the 1990s

And the meta-rule: resize before you compress. A 4000 px photo displayed at 800 px wastes 96% of its pixels whatever the format. Shrink to the display size first, then pick the format — that order saves more bytes than any format choice.

Common mistakes

  • PNG for photographs. A 5 MB PNG where a 200 KB JPEG would look identical.
  • JPEG for logos and text. Fuzzy edges and ringing — and no transparency, so the white box shows on dark backgrounds.
  • GIF for photos or long video. 256 colours banding, and files far bigger than a video element.
  • Re-saving JPEGs as masters. Every save loses quality. Keep a lossless master; export JPEG copies from it.
  • Serving only AVIF with no fallback. Older browsers get a broken image. The <picture> element costs three lines and removes the risk.
  • Uploading camera-sized images to a web page. Resize to the display size first — the biggest single win in web performance.

Try it: Image Converter

Convert the same photo to JPEG, PNG and WebP in the Image Converter and compare the file sizes yourself — the numbers in this guide stop being abstract the moment you see them.

Open the Image Converter →

Keep learning

Frequently asked questions

Which format gives the smallest file?

Usually AVIF, then WebP, then JPEG for photos — AVIF is often half the size of JPEG at the same visible quality. For graphics with flat colours and text, PNG or lossless WebP wins. The only reliable answer is to convert the same image and compare, which the Image Converter does in seconds.

Does WebP work in all browsers?

In every modern browser, yes — Chrome, Edge, Firefox and Safari have all supported it since 2020–2022. Only very old browsers (Internet Explorer, Safari before 14) lack it, which is what the JPEG fallback in the <picture> element is for.

Can I convert between formats without losing quality?

Lossless-to-lossless (PNG to lossless WebP) is exact. Anything to or from a lossy format loses something — JPEG to PNG keeps the JPEG's existing artefacts and just makes a bigger file. Convert from the best-quality master you have, not from a JPEG copy.

What about SVG?

SVG is a vector format — shapes and text described as maths, not pixels — so it scales to any size with no quality loss and tiny files. It is the right choice for logos, icons and diagrams, but it cannot hold a photograph.

What is the best format for screenshots?

PNG: lossless, so text stays sharp, and it compresses flat interface colours very well. If the screenshot contains a photo, WebP lossless is a good smaller alternative.