Most “convert JPG to WebP” results send you to a website where you upload your photo, wait, and download the result. That’s fine for one throwaway image. It’s a bad idea for anything private — client photos, screenshots of internal tools, family pictures — because the file leaves your machine and lands on someone else’s server.
There’s a cleaner way that’s free, works offline, and handles one file or ten thousand: run Google’s own cwebp tool inside WSL. It’s the same encoder behind most WebP conversions, it installs in seconds, and nothing you convert ever gets uploaded anywhere.
This guide covers the install, the single-file command, and a batch loop for a whole folder. If you don’t have WSL yet, set it up first with our WSL install guide — it’s one command and a reboot.
Why cwebp instead of an online converter
cwebp is the command-line encoder from Google’s WebP project. It takes a JPG (or PNG, TIFF) and writes a .webp file, with direct control over quality and compression. Three things make it worth the small setup:
- Nothing is uploaded. The conversion happens on your own disk. For confidential or work files, that alone settles the question.
- It batches. One short loop converts an entire folder. No dragging files in one at a time, no per-file upload limits.
- It’s free with no catch. No watermarks, no “sign up to download,” no daily cap.
The trade-off is a one-time setup and typing a command instead of clicking. Once it’s in place, converting is faster than any website.
Before you start
- WSL installed with a Linux distro (Ubuntu is fine)
- Your JPG files accessible from WSL
- A few minutes for the one-time install
Install cwebp in WSL
cwebp ships in the webp package. Open your WSL terminal (type wsl in Windows Terminal) and install it:
sudo apt update && sudo apt install -y webp
Confirm it’s there:
cwebp -version
You’ll get a version number back. That’s the whole setup — the encoder is now available for any folder you point it at.
Convert a single JPG to WebP
The basic command takes an input file, a quality value, and an output name:
cwebp -q 80 input.jpg -o output.webp
That’s it. input.jpg becomes output.webp in the same folder. The -q value (0–100) controls lossy quality: higher keeps more detail and makes a bigger file. For photos, 80 is a sensible default — close to the original, with a real size drop.
To find your JPGs, remember that your Windows drives are mounted under /mnt. A file on your desktop is reachable like this:
cd /mnt/c/Users/YourName/Pictures
cwebp -q 80 photo.jpg -o photo.webp
Check the result against the original:
ls -lh photo.jpg photo.webp
Batch convert a whole folder
This is where the command line pulls ahead of any website. To convert every JPG in the current folder and write a matching .webp next to each one, use a short loop:
for f in *.jpg; do cwebp -q 80 "$f" -o "${f%.jpg}.webp"; done
What it does, line by line:
for f in *.jpgwalks every.jpgin the folder."$f"quotes the filename so spaces don’t break it."${f%.jpg}.webp"strips the.jpgand adds.webp, sobeach.jpgbecomesbeach.webp.
Your original JPGs are left untouched — you end up with both files. To also catch uppercase .JPG and .jpeg, widen the pattern:
for f in *.jpg *.JPG *.jpeg; do [ -e "$f" ] && cwebp -q 80 "$f" -o "${f%.*}.webp"; done
The [ -e "$f" ] check skips a pattern that matches nothing, so you don’t get an error when, say, there are no .jpeg files.
Tuning quality and size
-q is the dial you’ll reach for most. A few practical points:
- Photos: stay in lossy mode.
-q 80is the default to beat; try-q 75if you want smaller,-q 90if you’re keeping fine detail. - Graphics, logos, screenshots: use lossless instead. Lossy compression smears sharp edges and flat color, while lossless keeps them crisp:
cwebp -lossless input.png -o output.webp
- Squeeze a bit more out of lossy files with
-m 6(slowest, best compression method) and-mtfor multithreading:
cwebp -q 80 -m 6 -mt input.jpg -o output.webp
cwebp options you'll actually use
| -q <0-100> | Lossy quality; 80 is a good photo default |
|---|---|
| -lossless | Lossless mode for graphics/screenshots |
| -m <0-6> | Compression effort; 6 is smallest but slowest |
| -mt | Use multiple threads |
| -resize <w> <h> | Resize while converting (0 keeps aspect) |
| -o <file> | Output WebP filename |
You can even resize during conversion, which is handy for web images you don’t need at full resolution:
cwebp -q 80 -resize 1600 0 input.jpg -o output.webp
The 0 for height tells cwebp to keep the aspect ratio. If you need to resize a lot of images as a separate step, see our guide on batch resizing images from the command line.
Going the other way, and other formats
This same toolchain handles related jobs. To turn WebP files back into JPG or PNG, see convert WebP to JPG or PNG. If your source images are PNGs rather than JPGs, the approach barely changes — there’s a dedicated walkthrough in bulk convert PNG to WebP, including when lossless is the better choice.
Wrapping up
Converting JPG to WebP doesn’t need a website or a paid app. cwebp inside WSL does it for free, offline, and in bulk: cwebp -q 80 input.jpg -o output.webp for one file, a short for loop for a whole folder. Because it runs locally, nothing you convert is ever uploaded — which makes it the safer choice for anything you wouldn’t want sitting on a stranger’s server.
Install it once, keep the loop handy, and folder-sized conversions become a single line you can rerun any time.