How it works — the honest version

No AI, no cloud, no magic. CompressToKB uses your own browser's image encoder and a search algorithm from the 1960s to land your file on a number. Here is exactly what happens when you press Compress.

Step 1: Check whether work is needed at all

If your file is already under the target and you have not asked for a different format, the tool keeps the original untouched and tells you. Re-encoding an already-small JPG would only shave quality for no benefit.

Step 2: Binary-search the quality setting

For JPG and WebP, file size rises smoothly as the encoder's quality setting rises. That makes the perfect setup for a binary search:

  1. Encode at quality 100%. Too big? The answer lies below.
  2. Encode at 50%. Too small means we can afford more quality; too big means less.
  3. Halve the remaining range and repeat — about a dozen rounds in total.

The last encode that still fits under your target is kept. Because each round halves the uncertainty, the result typically lands within a few percent of the target — quality settings are coarse enough that landing within roughly ±5% is what "hitting the target" honestly means, and the tool always shows the real final size rather than rounding it to the number you asked for.

One wrinkle: browser encoders internally round quality to whole-percent steps, so occasionally the best full-size encode lands well under the target — the next quality step up would overshoot it entirely. When that happens, the tool nudges the dimensions down a few percent at a time and searches again; a slightly smaller canvas shifts the size curve just enough that a higher quality step fits, landing much closer to your number.

Step 3: If quality is not enough, shrink the dimensions

Some images cannot reach a small target at any quality — a noisy, detailed photo at quality 2% is still too big at full size, and illegible besides. When the full-size search fails, the tool binary-searches a scale factor the same way (100%, 50%, 75%…) and runs the quality search again at each scale, keeping the largest dimensions that fit. Fewer pixels at decent quality almost always looks better than full-size pixels at terrible quality. The result line under each image reports the final dimensions, so this never happens silently.

The PNG exception

PNG is lossless: it has no quality setting, so step 2 does not exist for PNG output. Only the dimension search applies, which is why a photographic PNG may need to shrink a long way to reach 50 KB — and why the PNG page suggests JPG for photos. This is a property of the format, not a limitation of this site.

The ZIP file

"Download all as ZIP" assembles the archive in your browser too. It uses a small purpose-written ZIP writer in store mode (entries are packed without further compression — your images are already compressed, so re-compressing them would gain almost nothing) with proper CRC-32 checksums, which is why any standard unzip tool can open it.

Privacy, verifiably

All decoding and encoding happens through the Canvas API in your browser tab. There is no upload endpoint for this tool to send anything to. If you want proof rather than promises: open your browser's developer tools, switch to the Network tab, and compress an image — the only requests you will see are the ones that loaded this page.