Compress image to a target KB size

Choose images, enter a target size and select JPEG or WebP output. Compression runs locally and reports whether each file fits.

Choose images after JavaScript loads. Files are processed in your browser.

How it works

The tool checks JPEG, PNG and WebP dimensions within the first 1 MB of headers before decoding; missing, invalid or oversized dimensions are rejected. The browser then decodes each image and draws it onto a canvas. Canvas exports JPEG or WebP using a quality value from 0 to 1, as defined by WHATWG HTML. Original EXIF metadata is not copied. JPEG output uses a white background.

Our search policy tries quality 1 and 0.1, then up to 8 binary-search steps when the target is bracketed. If the quality floor is too large, dimensions shrink to 80%, rounded down to whole pixels with a minimum of 1. At most 24 shrink steps are attempted. Encoder sizes are browser-dependent and need not be perfectly monotonic; this is a bounded search, not a guarantee of optimal quality.

target bytes = floor(target KB × 1,000)
size reduction (%) = (original bytes − output bytes) ÷ original bytes × 100

A result meets the target when its exact byte count is at most the target. Displayed KB values are rounded to two decimal places; comparisons use whole bytes. Limits of 20 files, 30 MB per file and 40 million decoded pixels are local resource policies.

Worked examples

A 100 KB target

100 × 1,000 = 100,000 bytes. An output of 100,000 bytes fits; 100,001 bytes does not.

Resizing and savings

A 2,000 × 1,000 image becomes 1,600 × 800 after one resize step. If its size falls from 250,000 to 100,000 bytes, the reduction is 60%. These are illustrative sizes, not a compression promise.

Frequently asked questions

Can I compress to 20, 50 or 200 KB?
Enter that target. Very small targets may require substantial resizing. If the search cannot reach it, the download is explicitly marked over target.
Does PNG stay transparent?
Choose WebP output to retain transparency. JPEG output composites transparent areas onto white. This tool does not export PNG.
Will the image look identical?
No. Re-encoding is lossy and resizing discards detail. Inspect the downloaded image before using it.
Are my images uploaded?
No. Processing and downloads happen locally. Batches run one file at a time.
What happens to metadata and animation?
Source metadata is not copied to the canvas export. Animated inputs become a still frame. For metadata removal without re-encoding JPEG or PNG image data, use the related metadata remover.

Sources

Last reviewed 2026-11-14. The method is written out above so you can check our math.