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?
Does PNG stay transparent?
Will the image look identical?
Are my images uploaded?
What happens to metadata and animation?
Sources
- WHATWG — createImageBitmap allocation (checked 2026-11-14)
- PNG — IHDR dimensions (checked 2026-11-14)
- ITU-T T.81 — JPEG frame headers (checked 2026-11-14)
- Google — WebP container (checked 2026-11-14)
- Google — WebP lossless header (checked 2026-11-14)
- WHATWG HTML — serializing bitmaps to a file (checked 2026-11-14)
- BIPM — SI prefixes (checked 2026-11-14)
Last reviewed 2026-11-14. The method is written out above so you can check our math.