Skip to main content
Images Performance Web

How to compress images for the web

A practical guide to reducing image file size for faster web pages, including which format to pick, what quality setting to use and how to check the result.

The Tools Today6 min read

Images are usually the heaviest thing on a web page. A single photograph shot on a modern phone can weigh 5 MB, and a page with six of them can easily take longer to load than the rest of the site combined. Compressing those images is the single highest-leverage performance change most sites can make, and the good news is that modern encoders make it nearly painless.

Why images get so large

A camera sensor records several megapixels of colour data. A modern JPEG stores that data in a lossy format, throwing away information the eye is unlikely to notice. The issue is that camera software errs on the side of caution: it preserves enough detail for you to crop and re-edit the file later, which is exactly what most people never do. By encoding the image for its intended use — a 640-pixel-wide thumbnail does not need the same data as a full-screen hero — you can often cut the file size by 70 or 80 per cent with no visible difference.

Choosing the right format

  • JPEG: the right choice for photographs. Excellent compression, no transparency support.
  • PNG: the right choice for screenshots, logos and anything needing sharp edges or transparency. Keep the pixel count low.
  • WebP: a modern format that beats JPEG by around 30 per cent at the same quality, and supports transparency. Supported by every current browser.
  • AVIF: the newest format, with the best compression of all, but slower to encode and not supported everywhere yet.

What quality setting to use

For photographic content, a quality of 75 to 85 on the usual 0–100 scale is the sweet spot. Below about 60 you will start to see blocking artefacts around high-contrast edges; above 90 the file grows quickly while the perceived improvement is minimal. For screenshots and line art, where the edges are sharp and the palette is small, PNG is usually better than any lossy format, but the file should be resized first.

Do not forget the dimensions

Compression and resizing are different operations, and both matter. A 4000-pixel-wide photo displayed in a 800-pixel column still carries three times the necessary detail. Resizing first, then compressing, gives the smallest possible file for the visual result you want. Most tools that compress images offer both, and running them in that order is worth the extra few seconds.

How to check the result

Compare the compressed file against the original at 100 per cent zoom, paying particular attention to text, faces and sharp diagonals. Then load the page and watch the transferred size in your browser’s network panel. Remember to compare against the previous file, not against an absolute number: what matters is the ratio, and a good compressor should achieve three to five times smaller for typical photographs.

Tools mentioned in this guide

← Back to all guides

Your privacy, your choice

We use cookies to understand how the site is used and to show relevant ads. Every tool on this site runs entirely in your browser, so the files and text you process are never uploaded. Read our privacy policy.