How to Convert Images to WebP Format: Complete Guide (2026)
Published March 28, 2026 • 14 min read
WebP saves you 25-35% in file size compared to JPEG and PNG with no visible quality loss. If you run a website and haven't switched yet, you're shipping unnecessary bytes on every page load. This guide covers every practical method to convert your images to WebP β from drag-and-drop online tools to automated build pipelines.
1. What Is WebP and Why Should You Use It?
WebP is an image format created by Google in 2010, built on technology from the VP8 video codec. It was designed with one goal: deliver the same visual quality as JPEG and PNG at significantly smaller file sizes. And it delivers on that promise consistently.
In lossy mode, WebP produces files that are 25-34% smaller than equivalent JPEG files at the same SSIM quality index. In lossless mode, WebP images are 26% smaller than PNGs on average. Those aren't theoretical numbers β Google tested across 1 million randomly sampled images from the web to arrive at those figures.
What makes WebP particularly useful is that it handles things JPEG and PNG can't do individually. JPEG gives you small photos but no transparency. PNG gives you transparency but at large file sizes. WebP does both β lossy compression with full alpha channel support. A product image with a transparent background that might be 800KB as a PNG can drop to 150KB as a lossy WebP with transparency, and you won't see the difference.
WebP also supports animation, which means it can replace GIF files. Animated WebP files are roughly 64% smaller than equivalent GIFs, with better color depth (24-bit vs GIF's 8-bit palette). If you're still using GIFs for short animations or UI demos, WebP is a direct upgrade.
The practical impact is straightforward: faster page loads, lower bandwidth costs, and better Core Web Vitals scores. For a typical e-commerce site with 50 product images per category page, switching from JPEG to WebP can cut image payload from 3MB to under 2MB β shaving 1-2 seconds off load time on mobile connections.
2. WebP Browser Support in 2026
Browser support was the main reason people hesitated to adopt WebP for years. That concern is now irrelevant. As of early 2026, WebP is supported by over 97% of browsers in use globally, according to Can I Use data.
Here's the current state:
| Browser | WebP Support Since | Notes |
|---|---|---|
| Chrome | Version 32 (2014) | Full lossy + lossless + animation |
| Firefox | Version 65 (2019) | Full support |
| Safari | Version 14 / macOS Big Sur (2020) | Full support on macOS and iOS |
| Edge | Version 18 (2018) | Full support |
| Opera | Version 19 (2013) | Full support |
| Samsung Internet | Version 4 (2016) | Full support |
The only browser that never supported WebP is Internet Explorer 11, which Microsoft officially retired in June 2022. IE11's global usage share is now below 0.15%. Unless your analytics show meaningful IE11 traffic (check β it almost certainly doesn't), you can serve WebP without any fallback and be fine.
That said, implementing a fallback is trivial using the HTML <picture> element, and it costs you nothing in terms of performance. We'll cover that in the fallbacks section below. For most sites, though, you can confidently use WebP as your primary and only web image format in 2026.
Safari's adoption in 2020 was the tipping point. Before that, roughly 15-20% of web users (iOS Safari + macOS Safari) couldn't see WebP images. Now every major platform β desktop, mobile, tablet β handles WebP natively.
3. WebP Quality Settings Explained
Getting the quality setting right is the difference between "saved 10% file size" and "saved 40% file size." WebP's quality parameter works differently from JPEG's, and understanding the nuances will help you make better decisions.
Lossy WebP Quality (the -q flag)
WebP's quality scale runs from 0 to 100, similar to JPEG. But the compression algorithm is more efficient, so a WebP at quality 80 typically looks as good as a JPEG at quality 85-90. The sweet spot for most photographic content is quality 75-85. Here's what each range actually means in practice:
- Quality 90-100: Barely any compression. Files are only 10-15% smaller than the original. Useful only for hero images where every detail matters and you're already optimizing elsewhere.
- Quality 75-85: The practical sweet spot. You'll save 30-45% compared to an equivalent JPEG, and the visual difference is imperceptible to most people, even on retina displays. Start here.
- Quality 60-74: Noticeable softening on close inspection, but perfectly acceptable for thumbnails, background images, and content where users won't zoom in.
- Quality below 60: Visible artifacts. Only use this for very small thumbnails or placeholder images.
Lossless WebP
Lossless mode preserves every pixel exactly. There's no quality slider β the output is mathematically identical to the input. Use lossless WebP for screenshots, diagrams, logos, UI elements, and any image with sharp edges, text, or flat color areas. Lossless WebP files are typically 26% smaller than equivalent PNGs.
Near-Lossless Mode
This is WebP's hidden gem that most guides skip. Near-lossless mode (activated with -near_lossless in cwebp) applies minimal preprocessing to the image before lossless compression. The preprocessing slightly modifies pixel values in areas where the change is invisible, which dramatically improves compression. A near-lossless WebP at level 60 can be 40-50% smaller than a standard lossless WebP, with changes that are literally invisible to the human eye. It's ideal for screenshots and graphics where you want near-perfect quality at much smaller sizes than true lossless.
One important detail: WebP's quality setting controls the compression-quality tradeoff, but the -m flag (method, 0-6) controls how hard the encoder works to find optimal compression. Higher values produce smaller files but take longer to encode. For batch processing, -m 4 is a good balance. For one-off conversions where you want maximum savings, use -m 6.
4. Method 1: Convert Online with ImgKit
If you need to convert a handful of images quickly, an online converter is the fastest path. ImgKit's Image to WebP converter runs entirely in your browser β your images never leave your device, which matters if you're working with client photos or sensitive content.
Here's how to use it:
- Open the tool β Go to img-kit.com/tools/image-to-webp/
- Upload your images β Drag and drop files onto the upload area, or click to browse. You can select multiple files at once. The tool accepts JPEG, PNG, GIF, BMP, and TIFF inputs.
- Adjust quality β Use the quality slider to set your target. The preview updates in real time so you can see the output before downloading. Start at 80 and lower it until you notice quality loss, then bump it back up one notch.
- Download β Click the download button to get your WebP files. For multiple images, you'll get a zip file.
The browser-based approach has a practical limit around 50MB per image (depending on your device's RAM). For larger files or hundreds of images, use the command-line method below.
One advantage of the online approach: you can visually compare before and after side by side. This is harder to do with command-line tools, where you'd need to open both files manually. If you're trying to find the right quality setting for a specific type of image (product photos, blog headers, etc.), start with the online tool to dial in your settings, then use those settings for batch processing.
5. Method 2: Convert with Command Line (cwebp)
Google's cwebp tool is the reference encoder for WebP. It's free, fast, and gives you full control over every encoding parameter. This is the method to use for batch processing or integrating WebP conversion into build scripts.
Installation
# macOS
brew install webp
# Ubuntu/Debian
sudo apt install webp
# Windows (via chocolatey)
choco install webp
Basic Conversion
# Convert a single image at quality 80
cwebp -q 80 photo.jpg -o photo.webp
# Lossless conversion
cwebp -lossless screenshot.png -o screenshot.webp
# Near-lossless at level 60 (great for graphics)
cwebp -near_lossless 60 diagram.png -o diagram.webp
Batch Conversion
Convert every JPEG in a directory:
# Linux/macOS β convert all JPEGs in current folder
for f in *.jpg; do
cwebp -q 80 -m 4 "$f" -o "${f%.jpg}.webp"
done
# Include subdirectories
find . -name "*.jpg" -exec sh -c 'cwebp -q 80 "$1" -o "${1%.jpg}.webp"' _ {} \;
# Convert PNGs too
for f in *.png; do
cwebp -q 85 -m 4 "$f" -o "${f%.png}.webp"
done
Useful Flags
-q 80β Quality (0-100). Start at 80 for photos.-m 4β Compression method (0-6). Higher = smaller files, slower encoding.-resize W Hβ Resize during conversion. Use 0 for one dimension to maintain aspect ratio.-mtβ Multi-threaded encoding. Faster on multi-core machines.-shortβ Print only the file size (useful in scripts).-print_ssimβ Print the SSIM quality score so you can objectively compare quality.
For the reverse operation (WebP back to PNG/JPEG), use dwebp: dwebp image.webp -o image.png.
6. Method 3: Convert in WordPress
WordPress 5.8+ has native WebP support, meaning you can upload WebP files directly to the media library. But that still requires you to convert images before uploading. For automatic conversion, you need a plugin or server-side solution.
Plugin Approach
The most reliable plugins for WebP conversion in WordPress:
- ShortPixel Image Optimizer β Converts on upload, serves WebP via CDN or rewrite rules. Free tier covers 100 images/month. Handles both new uploads and existing media library images.
- Imagify β Similar feature set to ShortPixel. Integrates with WP Rocket for serving. Good UI for bulk optimization.
- WebP Express β Free, open-source. Converts images on the server using cwebp or GD/Imagick. Configures .htaccess rules automatically for serving.
All three plugins follow the same pattern: convert the original upload to WebP, store both versions, and serve WebP to browsers that support it (which is all of them now).
.htaccess Rewrite Rules
If you prefer not to use a plugin, you can handle WebP serving at the server level. Add these rules to your .htaccess file to serve WebP versions when they exist:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} \.(jpe?g|png)$
RewriteCond %{REQUEST_FILENAME}.webp -f
RewriteRule ^(.+)\.(jpe?g|png)$ $1.$2.webp [T=image/webp,L]
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(jpe?g|png)\.webp$">
Header set Vary "Accept"
</FilesMatch>
</IfModule>
This checks if the browser accepts WebP, if the requested file is a JPEG or PNG, and if a .webp version exists alongside it. If all three conditions are true, it serves the WebP version. The Vary header ensures CDNs and proxies cache both versions correctly.
You'll still need to generate the WebP files β either with a cron job running cwebp, or with a plugin that handles conversion but lets you manage serving yourself.
7. Method 4: Convert with Node.js and Sharp
If you're building a Node.js application or have a JavaScript build pipeline, Sharp is the go-to library for image processing. It's built on libvips, which is significantly faster than ImageMagick or GraphicsMagick.
const sharp = require('sharp');
// Single image conversion
await sharp('input.jpg')
.webp({ quality: 80 })
.toFile('output.webp');
// With resize
await sharp('input.png')
.resize(1200, null, { withoutEnlargement: true })
.webp({ quality: 82, effort: 4 })
.toFile('output.webp');
// Lossless
await sharp('screenshot.png')
.webp({ lossless: true })
.toFile('screenshot.webp');
// Batch processing
const fs = require('fs');
const path = require('path');
const files = fs.readdirSync('./images')
.filter(f => /\.(jpe?g|png)$/i.test(f));
for (const file of files) {
const input = path.join('./images', file);
const output = path.join('./webp', file.replace(/\.\w+$/, '.webp'));
await sharp(input).webp({ quality: 80 }).toFile(output);
console.log(`Converted: ${file}`);
}
Sharp's effort parameter (0-6) is equivalent to cwebp's -m flag. The nearLossless option is also available: .webp({ nearLossless: true, quality: 60 }).
For build tool integration, use vite-plugin-image-optimizer or image-minimizer-webpack-plugin with Sharp as the backend. These automatically convert images during your build process, so you commit source images and deploy WebP.
8. Lossy vs Lossless WebP: Which to Choose
This decision is simpler than most guides make it. The rule of thumb: use lossy for photographs, use lossless for graphics. Here's a detailed breakdown:
| Criteria | Lossy WebP | Lossless WebP |
|---|---|---|
| Best for | Photos, complex images, gradients | Screenshots, logos, diagrams, text |
| Compression ratio | 25-34% smaller than JPEG | 26% smaller than PNG |
| Quality | Slight loss (usually invisible at q75+) | Pixel-perfect, identical to source |
| Transparency | Yes (with some quality loss in alpha) | Yes (perfect alpha) |
| File size (typical photo) | 50-150KB | 300-800KB |
| Encoding speed | Fast | Slower |
| Use case | Web delivery, thumbnails, galleries | Source preservation, pixel art, UI |
The gray area is product images with transparent backgrounds. Lossy WebP supports transparency, and at quality 80+, the alpha channel quality is good enough for most product shots. You'll get files 3-5x smaller than lossless. Test with your specific images β if you see fringing or artifacts around edges, bump quality to 90 or switch to lossless for that particular image.
For animated content, lossy is almost always the right choice. Lossless animated WebP files can be enormous because every frame is stored at full quality. Lossy animated WebP at quality 75 produces files that are 60-70% smaller than equivalent GIFs with much better visual quality.
Convert Your Images to WebP Now
Try ImgKit's free browser-based converter. No upload limits, no watermarks, no account required.
Open Image to WebP Converter9. Serving WebP with Fallbacks
Even though WebP support is universal in 2026, fallbacks are cheap insurance. The two main approaches are the HTML <picture> element and server-side content negotiation. Use one or both depending on your setup.
The <picture> Element
This is the simplest and most reliable approach. The browser picks the first source it supports:
<picture>
<source srcset="hero.webp" type="image/webp">
<source srcset="hero.jpg" type="image/jpeg">
<img src="hero.jpg" alt="Product hero image" width="1200" height="630" loading="lazy">
</picture>
The <img> tag acts as the final fallback. Browsers that understand <picture> will use the first matching <source>. Older browsers that don't understand <picture> ignore it entirely and just render the <img>. No JavaScript required, no layout shift, no extra requests.
You can combine this with responsive images for full optimization:
<picture>
<source srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w"
sizes="(max-width: 600px) 400px, (max-width: 1000px) 800px, 1200px"
type="image/webp">
<img src="hero-800.jpg" alt="Product hero" width="1200" height="630" loading="lazy">
</picture>
Server-Side Content Negotiation (.htaccess)
If you don't want to change your HTML, you can handle it at the server level. When a browser sends Accept: image/webp in its request headers (all modern browsers do), Apache can transparently serve the WebP version:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_URI} \.(jpe?g|png)$
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,L]
</IfModule>
AddType image/webp .webp
Header append Vary Accept
For Nginx, the equivalent configuration uses a map block to check the Accept header and a try_files directive to serve WebP when available. This approach means your HTML stays unchanged β you reference image.jpg and the server silently serves image.webp when the browser supports it.
The downside of server-side negotiation: CDN caching becomes more complex. You need to ensure your CDN varies cache by the Accept header, or you'll serve WebP to browsers that don't support it (or vice versa). Most modern CDNs handle this correctly, but verify with your provider.
10. WebP for E-commerce
E-commerce sites benefit disproportionately from WebP because they're image-heavy and every millisecond of load time affects revenue. Amazon found that every 100ms of latency cost them 1% in sales. For a smaller store, the impact per millisecond is even larger because users are less committed to your brand.
Product images are the biggest opportunity. A typical product page has 4-8 images (main photo, angles, zoom views, lifestyle shots). Converting these from JPEG to WebP at quality 82 typically reduces total image payload by 35-40%. On a category page with 20-40 products, that's the difference between a 4MB page and a 2.5MB page.
For product images with transparent backgrounds (common for catalog-style shots), WebP is transformative. A 1000x1000 product cutout that's 600KB as PNG drops to 80-120KB as lossy WebP with transparency. The visual quality is indistinguishable at quality 85.
CDN integration is straightforward. Cloudflare's Polish feature auto-converts to WebP. Cloudinary and imgix support on-the-fly WebP conversion via URL parameters. If you're using Shopify, it already serves WebP automatically through its CDN. WooCommerce stores should use one of the WordPress plugins mentioned above.
Don't forget about zoom images. High-resolution zoom views (2000x2000+) are where WebP savings are most dramatic in absolute terms. A 2MB JPEG zoom image becomes a 1.2MB WebP β saving 800KB per zoom interaction.
11. WebP vs AVIF: Should You Skip to AVIF?
AVIF is the newer format on the block, based on the AV1 video codec. It offers even better compression than WebP β roughly 20% smaller files at equivalent quality. So should you skip WebP and go straight to AVIF?
For most sites in 2026, the answer is: use WebP now, add AVIF as a progressive enhancement. Here's why:
AVIF browser support is good but not as universal as WebP. Chrome, Firefox, and Samsung Internet support it fully. Safari added support in version 16.4 (2023), but older iOS devices on earlier Safari versions still can't display AVIF. Global support is around 92% β solid, but that remaining 8% is significant enough to require fallbacks.
The bigger practical issue is encoding speed. AVIF encoding is dramatically slower than WebP β often 10-20x slower for equivalent quality. For a site with thousands of images, batch converting to AVIF can take hours where WebP takes minutes. This also makes on-the-fly conversion impractical for most setups.
AVIF also has a maximum image dimension of 8193x4320 pixels in the baseline profile. If you work with large panoramas or high-resolution images, you'll hit this limit. WebP supports up to 16383x16383.
The pragmatic approach: serve AVIF to browsers that support it, WebP as the primary fallback, and JPEG/PNG as the final fallback. The <picture> element makes this trivial:
<picture>
<source srcset="image.avif" type="image/avif">
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" alt="Description">
</picture>
But if you're only going to support one modern format, WebP is the safer, more practical choice today.
12. Common WebP Conversion Mistakes
After helping thousands of users convert images, these are the mistakes we see most often:
- Converting already-compressed JPEGs at high quality. If your source JPEG is already at quality 60, converting it to WebP at quality 95 won't recover lost detail β it just makes a larger file that preserves the JPEG artifacts. Always convert from the highest-quality source available. If you only have compressed JPEGs, convert at a similar or lower quality setting.
- Using lossy for screenshots and text. Lossy compression smears sharp edges. Screenshots, code snippets, and images with text should always use lossless WebP. The file will be larger than lossy, but the text will remain crisp and readable.
- Ignoring the alpha channel quality. When converting PNGs with transparency to lossy WebP, the alpha channel gets its own quality setting (
-alpha_qin cwebp). The default is 100, which is fine. But some tools reduce alpha quality along with image quality, causing ugly fringing around transparent edges. Check your edges after conversion. - Not setting width and height on img tags. This isn't WebP-specific, but it comes up during migration. When you switch image formats, make sure your
<img>tags still have explicitwidthandheightattributes. Without them, the browser can't reserve space before the image loads, causing layout shift (bad CLS scores). - Forgetting to update CSS background images. Most WebP migration guides focus on
<img>tags and forget about images referenced in CSS. Background images set viabackground-imagedon't benefit from the<picture>element. Use server-side content negotiation or CSS feature queries:@supports (background-image: url(test.webp)). - Batch converting without spot-checking. Not all images compress equally well. A batch conversion at quality 75 might look great for 95% of your images but produce visible artifacts on the other 5% (usually images with fine detail or text overlays). Always spot-check a sample after batch conversion.
13. Key Takeaways
- WebP delivers 25-35% smaller files than JPEG/PNG with no visible quality loss. There's no good reason not to use it in 2026.
- Browser support is 97%+. IE11 is the only holdout, and it's effectively dead.
- Use quality 75-85 for photos (lossy) and lossless mode for screenshots/graphics.
- For quick conversions, use ImgKit's online converter. For batch processing, use cwebp or Sharp.
- WordPress users should install ShortPixel, Imagify, or WebP Express for automatic conversion.
- Implement fallbacks with the
<picture>element β it's two extra lines of HTML. - Consider adding AVIF as a progressive enhancement, but WebP alone covers 97%+ of users.
- Always convert from the highest-quality source. Don't re-compress already-compressed images.
Related Tools
Related Articles
→ WebP Format Explained: Why It's the Future of Web Images → Image Compression Guide: Reduce File Size Without Losing Quality → Best Image Formats for Web: PNG vs JPG vs WebP vs AVIF → Image Optimization for Web: The Complete GuideHow do I convert an image to WebP?
The quickest way is to use an online converter like ImgKit's Image to WebP tool β upload your JPEG, PNG, or GIF and download the WebP version instantly. For batch conversion, install Google's cwebp command-line tool and run cwebp -q 80 input.jpg -o output.webp. Node.js developers can use the Sharp library for programmatic conversion.
Is WebP better than JPEG?
For web delivery, yes. WebP produces files 25-34% smaller than JPEG at the same visual quality, supports transparency (JPEG doesn't), and supports animation (JPEG doesn't). The only scenario where JPEG is preferable is for maximum compatibility with very old software or email clients that don't support WebP.
Does WebP support transparency?
Yes. WebP supports alpha channel transparency in both lossy and lossless modes. Lossy WebP with transparency produces files roughly 3x smaller than equivalent transparent PNGs, making it ideal for product images, logos, and icons that need transparent backgrounds.
What quality setting should I use for WebP?
For photographs and complex images, use quality 75-85 (lossy mode). This range gives you 30-45% file size savings with no visible quality loss on most displays. For screenshots, logos, and graphics with sharp edges or text, use lossless mode. For a balance between the two, try near-lossless mode at level 60.
Can all browsers display WebP images?
As of 2026, over 97% of browsers support WebP, including Chrome, Firefox, Safari (since version 14), Edge, Opera, and Samsung Internet. The only browser that never supported WebP is Internet Explorer 11, which was retired in 2022. You can safely use WebP as your primary image format without fallbacks for virtually all users.