# Compress Image to KB

URL: https://hifreetools.com/image/compress-image-to-kb

> Compress a photo to a specific target size in KB — the tool searches for the highest JPEG quality that fits, and scales down only if it must — all in your browser.

## Quick answer

To compress an image to a target size, upload it and enter the size you need in KB (for example 100). The tool automatically searches for the highest JPEG quality that fits under your target, scaling the dimensions down only if quality alone isn't enough. It reports the final size and the percentage saved, and runs entirely in your browser, so the photo is never uploaded.

The image is re-encoded as JPEG at varying quality levels using a binary search: it repeatedly halves the quality range to find the best quality whose file size stays at or under your target. If even low quality is still too large, it reduces the pixel dimensions step by step and searches again. Transparent areas are flattened to white, since JPEG has no transparency.

## Examples

- Email attachment limit: Target 100 KB → ≤ 100 KB JPG
- Small thumbnail: Target 30 KB → ≤ 30 KB JPG, possibly scaled
- Modest squeeze: Target 200 KB on a 1 MB photo → ≤ 200 KB, higher quality

## FAQ

**How does it reach my KB target?**
It binary-searches the JPEG quality to find the highest setting that stays under your target size, and scales the image down only if quality alone can't get there.

**Will it always reach my target?**
Almost always. If the target is extremely small for the image, it returns the smallest version it can make and tells you so.

**What format is the output?**
JPEG, because its quality setting allows precise size control. Transparency is flattened to a white background.

**Is my image uploaded?**
No. All compression happens in your browser; the photo never leaves your device.

**Does it reduce the dimensions?**
Only if needed. It first lowers quality; for very small targets it scales the pixel dimensions down in steps until one fits.

**How much quality will I lose?**
For loose targets, very little — the tool keeps the highest quality that fits. Tight targets require more compression and may visibly soften the image.


## Sources

- [MDN — Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API)
- [MDN — HTMLCanvasElement.toBlob()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "Compress Image to KB", https://hifreetools.com/image/compress-image-to-kb
