Compress JPEG Online — Reduce Image File Size Without Losing Quality
JPEG compression lets you reduce image file sizes by 40–80% with minimal visible quality loss. Here's how JPEG compression works, what settings to use, and how to compress...
JPEG compression is lossy — it permanently discards image data to reduce file size. Done correctly at the right quality setting, the visible quality loss is imperceptible to most viewers, while file sizes drop 50–80%. Done incorrectly, images show visible artifacts (blocky patches, color banding, ringing around edges).
Use the Image Compressor to compress JPEG images directly in your browser with quality control.
How JPEG compression works
JPEG uses a three-phase compression pipeline:
1. Color space conversion: Converts RGB to YCbCr, separating luminance (Y) from chrominance (Cb, Cr). Human vision is less sensitive to color detail than brightness detail, so JPEG compresses the chroma channels more aggressively.
2. Discrete Cosine Transform (DCT): Divides the image into 8×8 pixel blocks and applies DCT to each block, converting spatial data into frequency components. Low-frequency components represent gradual tonal changes; high-frequency components represent sharp edges and fine detail.
3. Quantization: Divides the frequency components by a quantization table — this is where data is permanently lost. High-frequency components (fine detail) are divided by larger values, effectively zeroing them out. The quality setting controls how aggressive this step is.
Higher quality = smaller quantization divisors = more data preserved = larger file.
Quality settings explained
JPEG quality is typically expressed as a 0–100 scale (though internally it maps to quantization tables, not a linear percentage).
| Quality | File size | Use case |
|---|---|---|
| 90–95 | 2–4× original JPEG | High-quality print, archival |
| 80–85 | 4–6× reduction | High-quality web, photography |
| 70–75 | 6–10× reduction | General web use — sweet spot |
| 50–60 | 10–15× reduction | Thumbnails, previews |
| Below 40 | Very small | Visible artifacts — avoid for photos |
The practical sweet spot is 75–85. At this range, artifacts are invisible to most viewers in normal viewing conditions, while file sizes are dramatically smaller than 95 quality.
A 3MB original JPEG:
- Quality 95 → ~600KB (5× reduction)
- Quality 85 → ~300KB (10× reduction)
- Quality 75 → ~150KB (20× reduction)
When JPEG vs PNG vs WebP
Use JPEG for:
- Photographs and photorealistic images
- Any image with gradual color transitions
- Content where small file size matters more than pixel-perfect accuracy
Don’t use JPEG for:
- Screenshots, diagrams, text images, logos — use PNG
- Images with transparency — JPEG doesn’t support alpha channel
- Images you’ll edit repeatedly — re-saving introduces additional quality loss each time
Consider WebP: Modern browsers (Chrome, Firefox, Safari 14+, Edge) support WebP, which offers better compression than JPEG at equivalent quality. A WebP at quality 80 is typically smaller than a JPEG at quality 80 with better perceived quality. The tradeoff: WebP is unsupported in some older browsers and non-browser contexts (email clients, older image viewers).
Progressive vs baseline JPEG
Baseline JPEG: Loads top-to-bottom. On slow connections, you see the image appearing from top to bottom.
Progressive JPEG: Stores multiple passes of increasing detail. On slow connections, you see a blurry full image that sharpens as data loads — better perceived performance.
Progressive JPEGs are slightly smaller than baseline for images over 10KB. For web use, progressive is the better choice. Most modern compression tools output progressive JPEG by default.
How to compress JPEG for the web
Target file sizes by context
| Context | Target size |
|---|---|
| Blog post hero image | 100–200KB |
| Thumbnail | 20–50KB |
| Product image (ecommerce) | 80–150KB |
| Background image | 150–300KB |
| Gallery image | 50–100KB |
Using the Image Compressor
- Open the Image Compressor
- Upload your JPEG (or PNG — PNG photos can often be converted to JPEG with large savings)
- Adjust the quality slider (start at 80)
- Compare the preview against the original
- Download when the quality/size balance is acceptable
All processing happens in your browser — images are never uploaded to a server.
Command-line with ImageMagick
# Basic quality reduction:
convert input.jpg -quality 80 output.jpg
# With progressive encoding:
convert input.jpg -quality 80 -interlace Plane output.jpg
# Batch compress all JPEGs in a directory:
for f in *.jpg; do
convert "$f" -quality 80 -interlace Plane "compressed_${f}"
done
# Check resulting file size:
ls -lh compressed_*.jpg
With Sharp (Node.js)
const sharp = require('sharp');
async function compressJpeg(inputPath, outputPath, quality = 80) {
await sharp(inputPath)
.jpeg({ quality, progressive: true })
.toFile(outputPath);
const { size: original } = await sharp(inputPath).metadata();
const fs = require('fs');
const outputSize = fs.statSync(outputPath).size;
console.log(`Reduced by ${Math.round((1 - outputSize / original) * 100)}%`);
}
compressJpeg('photo.jpg', 'photo-compressed.jpg');
With Pillow (Python)
from PIL import Image
import os
def compress_jpeg(input_path, output_path, quality=80):
img = Image.open(input_path)
# Convert to RGB if necessary (PNG with transparency, etc.):
if img.mode in ('RGBA', 'P'):
img = img.convert('RGB')
img.save(output_path, 'JPEG', quality=quality, optimize=True, progressive=True)
original_size = os.path.getsize(input_path)
compressed_size = os.path.getsize(output_path)
reduction = (1 - compressed_size / original_size) * 100
print(f"Reduced by {reduction:.1f}%: {original_size//1024}KB → {compressed_size//1024}KB")
compress_jpeg('photo.jpg', 'photo-compressed.jpg')
Recompression and generational loss
Each time you open and save a JPEG, you apply another round of lossy compression. This is “generational loss” — quality degrades with each save cycle.
Practical rule: Keep original source files lossless (uncompressed RAW, TIFF, or PNG) and generate compressed JPEGs from those originals. Never edit a compressed JPEG and save it as JPEG again.
If you need to edit a JPEG and the original is unavailable: work in a lossless format (convert to PNG, edit, then re-export to JPEG) to avoid recompression on top of recompression.
EXIF data and privacy
JPEG files contain EXIF metadata — camera model, capture date, GPS coordinates (if location was enabled when the photo was taken). When sharing images publicly, you may want to strip EXIF data.
# Strip EXIF with ImageMagick:
convert input.jpg -strip output.jpg
# Strip with ExifTool:
exiftool -all= output.jpg
The Image Compressor processes images locally — EXIF data stays in the browser and is never transmitted.
Related tools
- Image Compressor — compress JPEG and PNG in your browser
- Image Compression Guide — formats, algorithms, and tradeoffs explained
- Reduce Image Size — resizing vs compression for web optimization
Related posts
- AVIF Image Format — Better Compression Than WebP and JPEG — AVIF offers 50% smaller files than JPEG at equivalent quality. Learn browser sup…
- Image Compression Formats — JPEG, PNG, WebP, AVIF Compared — JPEG, PNG, WebP, and AVIF compress images differently. JPEG is lossy and best fo…
- Image Compression Guide — Reduce File Size Without Losing Quality — Image compression reduces file size by removing redundant data. Here's how lossy…
- Reduce Image Size Online — Compress Photos Without Visible Quality Loss — Reducing image size for web involves choosing the right format, resizing to actu…
- PNG to ICO — Convert Images to Favicon Format — PNG to ICO conversion creates the favicon.ico file browsers look for by default.…
Related tool
Compress JPEG, PNG, and WebP images in your browser. Adjustable quality, batch mode. Files never leave your device.
Written by Mian Ali Khalid. Part of the Frontend & Design pillar.