Shrink your JPG file without losing visible quality
Drop a JPG above, drag the quality slider, and download a smaller file in seconds. No sign-up, no upload — everything runs right in your browser. Perfect for cutting image sizes before posting to a website, sending by email, or hitting a strict upload limit.
Your file never leaves your device. The compression is done entirely by your browser using the built-in canvas API, so your photos stay private.
How to compress a JPG in 3 steps
- Choose your file — click the upload area or drag your JPG onto it.
- Set the quality — slide the quality control left to shrink the file more, or right to keep more detail. A value around 70–80 gives a good balance between size and sharpness for most photos.
- Download — click the download button to save the compressed JPEG to your device.
The tool shows the original size and the compressed size side by side, so you can see exactly how much you saved before you download.
Worked example: compressing a holiday photo
Say you have a phone photo saved as holiday.jpg that weighs 4.2 MB. That is too big to attach to most emails (many providers cap attachments at 5 MB, and slower connections make large photos painful).
| Quality setting | Output file size | Visual difference |
|---|---|---|
| 90 | ~1.8 MB | Virtually none |
| 75 | ~700 KB | Barely noticeable |
| 60 | ~380 KB | Slight softening in fine detail |
| 40 | ~200 KB | Visible compression artefacts |
For a typical email attachment or website hero image, quality 75–80 is the sweet spot. You save around 80% of the original file size with very little visible loss.
How to compress a JPG in code
If you need to automate JPEG compression in a script or CI pipeline, here are two minimal, copy-pasteable examples.
Python (Pillow library)
# pip install Pillow
from PIL import Image
img = Image.open('holiday.jpg')
img.save('holiday_compressed.jpg', format='JPEG', quality=75, optimize=True)
The quality parameter accepts 1–95 (95 is near-lossless). Setting optimize=True tells Pillow to run an extra pass that can shave a few extra kilobytes.
JavaScript (browser canvas)
// Runs in a browser — no libraries needed
async function compressJpg(file, quality = 0.75) {
const bitmap = await createImageBitmap(file);
const canvas = document.createElement('canvas');
canvas.width = bitmap.width;
canvas.height = bitmap.height;
canvas.getContext('2d').drawImage(bitmap, 0, 0);
return new Promise(resolve =>
canvas.toBlob(resolve, 'image/jpeg', quality)
);
}
The quality argument here is a float between 0 and 1. Pass 0.75 for roughly 75% quality — the same logic this page's tool uses under the hood.
How the compression works
JPEG compression (defined in the JPEG standard, maintained by the Joint Photographic Experts Group) works by dividing an image into small 8×8 pixel blocks and discarding fine detail the human eye is least sensitive to — mainly high-frequency colour shifts. Lowering the quality setting throws away more of that detail, which means a smaller file but also softer edges at very low settings.
This tool draws your image onto an HTML canvas element, then calls canvas.toBlob() with the JPEG MIME type and your chosen quality value. The browser's own image engine does the rest. Nothing is sent to a server.
When to use JPEG compression — and when not to
- Use it for photos and gradients — JPEG is designed for continuous-tone images like portraits, landscapes, and product shots.
- Use it before uploading to social media or a CMS — platforms like WordPress and Shopify often accept JPEGs but benefit from pre-compressed files that load faster.
- Skip it for logos, icons, and screenshots with text — JPEG introduces subtle colour smearing around hard edges. Use PNG or SVG for those.
- Skip it if you need a transparent background — JPEG does not support transparency. Convert to PNG instead if you need transparent areas.
- Skip it for lossless archiving — each time you save a JPEG at less than 100% quality, some detail is permanently lost. Keep a master copy in a lossless format (TIFF or PNG) if you plan to edit the image again later.
For more on JPEG quality and when lossy compression is worth the trade-off, see the MDN docs on canvas.toBlob(), which explains the quality parameter in depth.
Your data stays private
Many online image tools upload your photo to a remote server for processing. This tool is different: the entire compression runs locally in your browser using the canvas API. Your JPG is never transmitted anywhere, so there is no risk of your images ending up on a third-party server.
That matters especially if you are compressing personal photos, client work, or confidential product images.
One takeaway
Smaller JPEGs mean faster page loads, smaller email attachments, and fewer rejected uploads — and you can reach that in seconds without installing anything. Use the tool above to compress your JPG right now.