Guides

JPEG, PNG or WebP — which image format to use on your site

Illustration: the same photo on three scales showing different weights

There's a rule a lot of people have carried around since the 2000s: "need transparency, use PNG." It used to be right. It isn't anymore.

WebP does transparency just as well, and by Google's own numbers it comes out 26% smaller than PNG in lossless mode. So for the same image with a transparent background, you're paying a quarter extra out of pure habit.

Let's sort the three formats out and decide what to use.

What actually separates them

The core difference is what happens to the image during compression.

JPEG compresses lossily. It throws away detail the eye barely registers, and shrinks a lot in exchange. For photographs that's ideal: millions of shades, and losing some of them is invisible. For a screenshot with text it's bad: letters pick up dirty halos.

PNG compresses losslessly. Pixels come back exactly as they went in. It also does full transparency. The price is weight: a photo in PNG can be several times heavier than the same photo in JPEG.

WebP does both modes — lossy and lossless. Plus transparency in both. Plus animation. It's effectively one format instead of three.

Comparison table

| Criterion | JPEG | PNG | WebP | |---|---|---|---| | Compression | Lossy | Lossless | Both | | Transparency | No | Yes | Yes | | Animation | No | No (except APNG) | Yes | | Photo file size | Baseline | Much larger | 25–34% smaller than JPEG | | Lossless graphics size | Not suitable | Baseline | 26% smaller than PNG | | Browser support | Universal | Universal | All modern browsers | | Encoding speed | Very fast | Fast | Slower | | Good for | Photos | Almost nothing (see verdict) | Almost everything |

The 25–34% and 26% figures aren't eyeballed — they're Google's official numbers for WebP at comparable quality.

Who should use what

No fence-sitting:

Use WebP by default — for everything. Photos, screenshots, logos, icons, images with transparency. It's lighter than both competitors in its respective mode and supported by every modern browser (Safari since version 14, which shipped in 2020).

Use JPEG when someone downloads the image and takes it away. Exports, email attachments, print files, uploads into third-party systems. JPEG is understood by literally everything, including twenty-year-old software. Inside your own site, you don't need it.

PNG is barely needed today. One live use case: favicons and PWA icons, where the format is mandated by spec. Everything else, WebP does better and lighter.

The practical part

Don't convert your whole image library by hand. Do this instead:

  1. Find what's actually slow. Open DevTools → Network tab → filter to Img, reload, sort by size. Odds are the top three rows are 80% of the page weight. Fix those; leave the rest alone.
  2. Convert the heavy ones. cwebp -q 80 photo.jpg -o photo.webp, or any online converter. Quality 80 is the working sweet spot: no visible difference, noticeably smaller file.
  3. Don't forget pixel dimensions. No format saves a 4000×3000 image dropped into a 600-pixel-wide slot. Resize first, then convert — otherwise you save 30% where you could have saved 90%.
  4. Check nothing broke. Broken paths after renaming are a classic reason images stop loading.

How this fits into the bigger picture is in the breakdown of how to speed up your website.

What about AVIF?

AVIF compresses even harder than WebP and support is now nearly everywhere. But it encodes noticeably slower, and its edge over WebP is smaller than WebP's edge over JPEG.

The sensible strategy: move to WebP now, and add AVIF later as an extra source via <picture> if you end up chasing speed. Jumping straight to AVIF for the last few percent is the wrong priority while three-megabyte JPEGs are still sitting on the site.

What format should I accept from user uploads?

Accept whatever they give you — JPEG, PNG, HEIC from iPhones — and convert to WebP on your side before storing. Users shouldn't have to think about formats, and you shouldn't have to store their heavy originals. How the upload itself works is in the guide on adding image upload.

Does WebP hurt quality?

Only in lossy mode — same as JPEG, and at equivalent quality settings it looks no worse while weighing less. If quality is critical (a logo, a UI screenshot, graphics with hard edges), use WebP lossless: pixels are preserved exactly and the file still comes out lighter than PNG.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →