Compress to target size
Binary-search quality until you hit a file-size goal.
This runs in your browser. Nothing is uploaded.
About Compress to target size
Searches for the JPEG quality that brings your image in at or under a file size you name in kilobytes, running every encoding attempt in your browser.
Upload forms rarely ask for a quality setting. They ask for “under 500 KB” or “maximum 2 MB”, and then you are left nudging a slider, exporting, checking the size in your file manager and going round again. This page runs that loop for you: give it a number in kilobytes and it finds the setting that fits.
Behind the Target KB slider sits a binary search over JPEG quality. The image is encoded at the midpoint of the range, the resulting size is measured, and the search narrows towards the highest quality that still fits — eight encodes in total, between quality 0.10 and 0.95. The best passing attempt is what downloads, and the panel prints its size next to your original for confirmation.
The search only turns the quality dial. It never resizes, so asking a 12-megapixel photo to fit in 50 KB is a request no quality setting can satisfy — you will receive the quality-0.10 attempt, still over budget and visibly rough. Resize first when the target is aggressive. Output is always JPEG, so transparency is flattened and the search cannot go above 0.95.
How to use Compress to target size
- 1Drop your image onto the panel or click to browse.
- 2Set Target KB to the limit you need to come in under.
- 3Click Compress & download and wait — the image is encoded up to eight times while the search runs.
- 4Check the printed output size against your target before you submit the file anywhere.
What it won't do
- JPEG output only, so transparency is flattened.
- Never resizes to reach the target, so an aggressive goal on a large image will miss.
- Quality is searched between 0.10 and 0.95, so it cannot produce a near-lossless file.
Common questions
How do I compress an image to a specific file size?
Name the target in kilobytes and let the tool search for the quality that fits, which is what this page does. It re-encodes as JPEG at several quality levels and keeps the best result that comes in at or under your number. Guessing quality settings by hand and checking the file size afterwards reaches the same place much more slowly.
Will it hit my target size exactly?
No — it aims for at or under, never exactly on. Eight rounds of binary search approach your ceiling from below, so a 200 KB target typically yields something between 180 and 199 KB. Where the image cannot fit even at the lowest quality, you get the smallest attempt it managed, which will be over your target.
Why is this slower than the normal JPEG compressor?
Because it encodes your image eight times rather than once. Every pass is a full JPEG encode at a different quality, and its result decides where the search looks next. On a large photograph that adds up to a real wait. If you already know roughly what quality you want, the JPG compressor does a single pass and is done.
Can I target a size for PNG or WebP instead?
Not from this page — the search always produces JPEG. JPEG has the smoothest relationship between quality and file size, which is what makes the search converge reliably. For a WebP or AVIF size budget, compress at a quality you pick, look at the result, and adjust downwards if it came in over.
Related tools
Why this one doesn't upload your file
There is no server to upload to. This page is a static file, and the work happens in your browser using the same graphics and WebAssembly code that renders every other site you visit. Your file is read from disk into memory, processed, and handed back as a download. Once the page has loaded you can disconnect from the network entirely and it keeps working. The longer explanation