What is WebP Image Format?
WebP is a lossy and lossless image format by Google that delivers smaller file sizes than JPEG and PNG.
What is WebP?
WebP is Google's image format from 2010, built on top of VP8 video codec tech. It does lossy, lossless, transparency, and animation—basically JPEG, PNG, and GIF rolled into one. Google claims 25–34% smaller than JPEG at the same quality (SSIM) and 26% smaller than PNG for lossless. Safari finally added support in version 14 (September 2020), so now it works everywhere that matters—Chrome, Firefox, Edge, Safari, done.
For web performance, WebP directly cuts Largest Contentful Paint (LCP) by shrinking image payload. Images are usually the heaviest thing on a page. We've shipped WebP as the default on 50+ client projects. It's still our go-to unless we need AVIF fallback chains.
How it works
Lossy WebP uses predictive coding from VP8. Each pixel block gets predicted from already-decoded blocks, then you only encode the difference. It's how video codecs compress keyframes. Beats JPEG's DCT-only approach.
Lossless is a different beast—spatial prediction, color space transforms, LZ77 backreferences, Huffman coding. The alpha channel can be lossy-compressed separately, which PNG can't do.
Most teams don't hand-encode WebP. The conversion pipeline looks like this:
# Convert with cwebp (libwebp 1.4+)
cwebp -q 80 -m 6 input.jpg -o output.webp
# Or in a Node.js build pipeline using sharp
const sharp = require('sharp');
await sharp('input.jpg')
.webp({ quality: 80, effort: 6 })
.toFile('output.webp');
Next.js makes this automatic—next/image serves WebP (or AVIF) when the browser's Accept header says it can handle it. Astro's <Image /> from astro:assets does the same. Both handle responsive srcset and format negotiation without config.
The quality sweet spot we've landed on is quality: 75-82 for lossy WebP. Below 70, you get ringing artifacts around text and hard edges. Above 85, the size savings over JPEG vanish.
When to use it
WebP is the safe default for nearly every web project in 2026. Here's when it fits:
Use WebP when:
- You need broad browser support with no fallback chain—it works everywhere
- You're replacing both JPEG and PNG and want one format
- You need transparency with smaller files than PNG
- You're using Next.js or Astro's image components—WebP is already the default
- You want animated images without GIF bloat
Skip WebP (or pair it with AVIF) when:
- You're optimizing hero images where every KB matters—AVIF is typically 20% smaller at equivalent quality
- You're serving high-fidelity photography where AVIF's color retention beats WebP
- You need print-ready quality—stick with the original TIFF/PNG source
Our preferred stack is AVIF → WebP → JPEG as a format fallback chain using <picture> or framework-level negotiation.
WebP vs alternatives
| Feature | WebP | AVIF | JPEG | PNG |
|---|---|---|---|---|
| Lossy compression | ✅ 25-34% smaller than JPEG | ✅ ~50% smaller than JPEG | Baseline | ❌ |
| Lossless compression | ✅ 26% smaller than PNG | ✅ | ❌ | Baseline |
| Alpha transparency | ✅ | ✅ | ❌ | ✅ |
| Animation | ✅ | ✅ | ❌ | ❌ (APNG exists) |
| Browser support (2026) | ~97% global | ~93% global | 100% | 100% |
| Encode speed | Fast | Slow (3-10x slower) | Fast | Fast |
| Max dimensions | 16383×16383 | No hard limit | 65535×65535 | Spec-limited |
The encode speed difference is real. AVIF encoding with libavif or sharp runs 5-10x slower than WebP at equivalent effort. For build pipelines processing thousands of images, this matters. We often pre-generate AVIF at deploy time and use WebP as the real-time on-demand format.
Real-world example
We migrated an e-commerce client with ~4,200 product images from JPEG to WebP using sharp in a Next.js 14 pipeline. Average image size dropped from 145 KB to 98 KB—32% reduction. Total page weight on category pages (40 thumbnails each) dropped by roughly 1.9 MB. LCP improved from 3.1s to 2.3s on mobile 4G (measured via CrUX field data over 28 days).
The entire conversion pipeline ran in under 8 minutes on a standard CI runner. We later added AVIF as a progressive enhancement, which shaved another 15-20% off for Chrome and Firefox users. WebP remained the workhorse fallback that covered Safari and older browsers.