Compress to target size
Binary-search quality until you hit a file-size goal.
Runs in this tab. The file stays here.
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're 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 per round, 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.
Quality is the first dial, not the only one. If even quality 0.10 is over your number, the tool shrinks the pixel dimensions by about 30 percent and runs the whole search again, repeating up to eight times, and the readout says "(scaled)" when that happened. That is how a 12-megapixel photo can still land under 50 KB, and also why the result can come back much smaller in pixels than what you dropped in. If you care about the dimensions, resize deliberately first. Output is always JPEG, so transparency is flattened and the search can't 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 at least eight times while the search runs, more if it has to shrink the dimensions.
- 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.
- Steps dimensions down (about 30 percent per step, up to eight steps) when quality alone can't reach the target, and there's no switch to turn that off.
- A very small target on a large image can still miss after every step; the page then hands back the lowest-quality attempt.
- Quality is searched between 0.10 and 0.95, so it can't 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. If no quality fits, the tool steps the dimensions down and searches again. Only when every step has failed do you get the last quality-0.10 attempt, which will be over your target.
Why is this slower than the normal JPEG compressor?
Because it encodes your image at least 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. When quality alone can't fit, each dimension step repeats the eight-pass search, so a big photo with a small target can mean dozens of encodes. 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