Raster: a grid of dots
The picture is saved as coloured pixels. Great for photos, but it blurs or turns blocky when you enlarge it.
JPEG, PNG, GIF, WebP, AVIF and SVG all show a picture. They store it in different ways, and that decides how big the file gets, how sharp it stays and what it can do.
Every format is a trade. It gives up something to be good at something else, and none of them wins at everything. Start with the biggest trade, then the four smaller ones.
The same moon, stored two ways. Drag the slider to enlarge both.
A photo has millions of blended colours, so it is saved as a grid of coloured squares. At its real size the squares are too small to see. Enlarge it and each one grows, so edges step and then turn into blocks.
A logo is a few flat shapes, so it can be saved as the shapes themselves: a circle here, a curve there. The browser redraws them at every size, so the edge stays clean at 1× and at 16×.
Shapes cannot hold a real photo, and pixels cannot grow without losing detail. That split is why both families exist.
Inside the pixel family, each format picked a different balance of these.
A smaller file loads faster. Lossy formats get there by dropping detail you rarely notice. Lossless formats keep every pixel and end up heavier.
An icon has to sit on any colour. JPEG always fills the background with a solid colour. GIF can hide a pixel fully but cannot fade an edge. The rest can fade edges smoothly.
GIF made short loops possible in 1987, but the files are large. WebP and AVIF play the same loop at a fraction of the size.
Each new format fixed a limit of the ones before it. A format only helps once browsers and apps can open it, so the older ones stay around as a safe fallback.
Every format belongs to one of two families. Knowing which one you have explains most of what follows.
The picture is saved as coloured pixels. Great for photos, but it blurs or turns blocky when you enlarge it.
The picture is saved as lines, curves and fills. It stays crisp at any size, but cannot hold a real photo.
Raster files are squeezed to save space. Some throw away detail you will rarely notice, others keep every pixel.
Drops tiny details your eye skips. Much smaller.
Packs everything and gets it back exactly.
One line on what each one is, what it can do, and where it fits best.
The classic photo format. Small files, but it smudges sharp edges and text.
Pixel perfect and lossless, with smooth transparency. Heavy for photos.
The old animation format. Only 256 colours, so photos look grainy and files get big.
Made for the web. Does what JPEG, PNG and GIF do, in smaller files.
The newest one. Smallest photo files and rich HDR colour, but slower to create.
A picture written as code. Sharp at any size and easy to recolour with CSS.
One picture, saved six ways at similar quality. Switch between a photo and a flat logo to see how the winner changes.
Shorter bar means a faster page
Rough, illustrative figures. Real sizes depend on the picture, the encoder and the quality you pick.
The same six formats seen three ways. Switch the view to compare what each can do, how it does on size and speed, and what it improved over the ones before it.
| Format | Type | Compression | Transparency | Animation | Colours | Browsers |
|---|---|---|---|---|---|---|
| JPEG.jpg | Raster | Lossy | No | No | 16.7 million | All |
| PNG.png | Raster | Lossless | Full | APNG only | Up to billions | All |
| GIF.gif | Raster | Lossless | On or off | Yes | 256 per frame | All |
| WebP.webp | Raster | Both | Full | Yes | 16.7 million | Modern |
| AVIF.avif | Raster | Both | Full | Yes | Billions, HDR | Modern |
| SVG.svg | Vector | None needed | Full | CSS or SMIL | Any | All |
| Format | Photo size vs JPEG | Photo compression | Flat graphic compression | Saving speed | Loading speed |
|---|---|---|---|---|---|
| JPEG | Baseline | Fast | Fast | ||
| PNG | Often 5 to 10 times bigger | Fast | Fast | ||
| GIF | Bigger, and grainy | Fast | Fast | ||
| WebP | About 25 to 35% smaller | Moderate | Fast | ||
| AVIF | Often about half the size | Slow | Moderate | ||
| SVG | Not for photos | n/a | Instant | Depends on detail |
| Format | Arrived | Improved on | What got better | What it still lacks |
|---|---|---|---|---|
| GIF | 1987 | Nothing, it came first | Shared pictures and short loops online | Only 256 colours, hard-edged transparency |
| JPEG | 1992 | GIF for photos | Full colour photos at a fraction of the size | No transparency, fuzzy edges on text |
| PNG | 1996 | GIF for still images | Millions of colours, soft transparency, no quality loss | Large files for photos |
| SVG | 2001 | Raster logos and icons | Sharp at any size, tiny files, styleable with CSS | Cannot store photos; clean uploaded files, since they can carry scripts |
| WebP | 2010 | JPEG, PNG and GIF | One format for photos, transparency and animation, in smaller files | 8-bit colour only, no HDR |
| AVIF | 2019 | WebP and JPEG | Even smaller photos, 10 and 12-bit colour, HDR | Slow to save, heavier to decode on old phones |
Ask these questions in order and stop at the first yes.
<!-- 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="Team at the office" width="1600" height="1067" loading="lazy">
</picture>
Why this matters: you ship the smallest file to new browsers and a JPEG to old ones, without writing any script.
Short answers to what comes up when you put images on a real site.
AVIF first, then WebP, with JPEG as the fallback. A <picture> element lets the browser take the first one it supports.
<picture> <source srcset="photo.avif" type="image/avif"> <source srcset="photo.webp" type="image/webp"> <img src="photo.jpg" alt="…" width="1600" height="1067"> </picture>
For screenshots, interface images and anything with small text, where every pixel has to stay exact. Lossless WebP does the same job in a smaller file.
Yes. They stay sharp at any size and are usually the smallest option. Clean any SVG a user uploads, since it can carry scripts.
Rarely. Animated WebP and AVIF are far lighter. For anything longer than a few seconds, a short MP4 or WebM video beats all three.
Every current browser opens WebP, and all current major browsers open AVIF. Older phones and apps may not, so keep a JPEG or PNG fallback.
Often more. Serve each image at the size it is shown, using srcset and sizes, so a phone never downloads a desktop-sized file. Set width and height so the page does not jump while it loads.
Images further down the page, yes: add loading="lazy". Keep the main image at the top loading straight away, and give it fetchpriority="high" so it shows first.
Keep the original file and export every format from it. Re-saving a lossy file loses a little more detail each time.