
To compress an image to 40KB, open Dokurapi's free Compress Image tool, choose the photo, type 40 in the Custom target (KB) box, leave Pixel size on Shrink if needed, press Compress photo, and read the Output figure before you press Download result. The tool aims 6% below your number, so a 40 KB target means a JPG of at most 37,600 bytes. The photo never leaves your device; everything runs inside the browser tab. In our test a 5.00 MB phone photo came out at 30,836 bytes, 1474 x 1106 pixels at JPEG quality 32%, in well under a second.
40 KB sits in an awkward middle. It is too small for a full size phone photo, so the tool has to reduce the pixel count as well as the quality, yet it is roomy enough that all five of our test images fitted, including two photos of a printed page that failed at 20 KB. This guide covers the steps, how the tool searches for a result, real numbers from five test images, how the same files behave at 20 KB and 50 KB, and what to check before you upload. If your limit is different, see our guides to 20 KB, 50 KB and 100 KB.
Steps to compress an image to 40KB
You need no account and no app. The tool writes a new JPG and leaves your original file untouched.
- Check the current size first. The file manager on your phone or the file properties on a computer show it. If the image is already a JPG under 40 KB, upload it as it is.
- Open the Compress Image tool and choose one image. It accepts JPG, PNG and WebP. iPhone photos saved as HEIC need converting first; our HEIC to JPG guide shows how.
- Type 40 in the Custom target (KB) box. The preset menu offers 100 KB, 200 KB, 500 KB, 1 MB and 2 MB, so 40 needs the custom box. A number in the custom box always wins over the menu.
- Keep Pixel size on Shrink if needed. At 40 KB this matters: with Keep original size, a large photo cannot reach the target at all, as our test further down shows.
- Press Compress photo. Even a 5 MB photo finished in under a second on a laptop, although the tool tried 20 versions behind the scenes.
- Read the result box and open the file. It lists the original size, the output size, the final quality and the pixel size. Zoom in on the face, the text or the signature before you upload.

Ready to try it? The tool is free and runs in your browser.
Open the Compress Image toolHow the tool gets an image down to 40KB
The tool works in two stages. In the first, it draws the image on a canvas with the longest side capped at 2,400 pixels and saves a JPG at the starting quality, 84% by default. If the file is still above the safe line, it lowers the quality by 10 points and tries again, up to seven times, never going below 18%. The quality value goes straight to the browser's own JPEG encoder, as described in MDN's toBlob reference.
For our phone photo the first stage was not enough: even at quality 18% the 2,400 pixel image weighed 60,271 bytes. So the second stage began. The tool shrinks the width and height by a factor based on how far the file still is from the target, then retries at quality 72%, 58%, 45% and 32%, keeping the smallest file. It repeats with a smaller size until the file fits, and it never goes below 640 pixels on the long side.
The phone photo needed three rounds, at 2,040, 1,734 and 1,474 pixels, and the twentieth attempt fitted. The safe line itself is 40 x 1,000 x 0.94 = 37,600 bytes. The tool counts 1 KB as 1,000 bytes, the decimal convention explained by NIST, and the 6% margin covers portals that count 1 KB as 1,024 bytes or round sizes up. Our general guide to compressing an image uses the same logic for every target.
What the live tool returned for five test images
We made five synthetic images with no personal data: a colourful phone style photo at 4000 x 3000 pixels, a photo of a printed page at 3000 x 4000, a 1500 x 1000 crop of that page, a scanned signature at 1600 x 600, and a small 480 x 640 portrait style photo of the kind used as a pas foto. Each went through the live tool with a 40 KB custom target and the default settings, once in English and once in Indonesian, with identical results.
| Test image | Original | Result | Quality and pixels | What happened |
|---|---|---|---|---|
| Signature scan | 278 KB, 1600 x 600 | 29,772 B | 34%, 1600 x 600 | Quality only, sixth step |
| Small photo | 140 KB, 480 x 640 | 31,116 B | 44%, 480 x 640 | Quality only, fifth step |
| Phone photo | 5.00 MB, 4000 x 3000 | 30,836 B | 32%, 1474 x 1106 | Three pixel rounds, 20 attempts |
| Cropped document | 682 KB, 1500 x 1000 | 31,839 B | 45%, 723 x 482 | Four pixel rounds |
| Document photo | 5.27 MB, 3000 x 4000 | 34,000 B | 32%, 604 x 805 | Three pixel rounds, closest to the line |
The pattern is clear. Images that are already small in pixels, like the signature and the portrait, reach 40 KB by lowering quality alone and keep their full size. Large photos must lose pixels, and busy detail costs the most: the page full of small text ended at 604 pixels wide, while the smoother phone photo kept 1,474. File size alone tells you little; the 682 KB crop ended smaller in pixels than the 5 MB phone photo because text and paper grain are expensive to encode.
40KB compared with 20KB and 50KB
Forms that ask for a small photo usually pick a round number, and the difference between 20, 40 and 50 KB is bigger than it sounds. We ran the same five images through the same algorithm at all three targets. The 40 KB column is the live test above; the 20 KB column matches our 20 KB test.
| Test image | 20 KB target | 40 KB target | 50 KB target |
|---|---|---|---|
| Signature scan | 18,325 B at 18%, 1600 x 600 | 29,772 B at 34%, 1600 x 600 | 42,340 B at 44%, 1600 x 600 |
| Small photo | 16,261 B at 24%, 480 x 640 | 31,116 B at 44%, 480 x 640 | 45,971 B at 64%, 480 x 640 |
| Phone photo | 18,726 B at 32%, 1065 x 799 | 30,836 B at 32%, 1474 x 1106 | 42,406 B at 32%, 1734 x 1301 |
| Cropped document | Not reached: 20,656 B at 640 x 428 | 31,839 B at 45%, 723 x 482 | 37,417 B at 32%, 783 x 523 |
| Document photo | Not reached: 24,351 B at 479 x 640 | 34,000 B at 32%, 604 x 805 | 43,172 B at 32%, 698 x 930 |
Doubling the budget from 20 to 40 KB is what rescues documents: both page photos failed at 20 KB even at the 640 pixel floor, and both fit comfortably at 40 KB. Going from 40 to 50 KB mostly buys sharper small images, such as the portrait jumping from quality 44% to 64%. If a form gives a range, such as 20 to 50 KB, aim near the top of it; the extra bytes go straight into detail.
How a 40KB image looks
For a photo of a person or a scene, 40 KB at around 1,500 pixels looks fine on a phone and acceptable on a laptop. Quality 32% softens fine texture, but faces and shapes stay clear, and the result is much sharper than a tiny image saved at high quality. For a portrait the size of a pas foto, 480 x 640 pixels at quality 44% is close to what portals expect anyway. Our guides to 3x4 photo size and passport photo size list the pixel sizes forms usually want.
Documents are the hard case. At 604 x 805 pixels and quality 32%, our page photo was still readable at normal zoom, as the comparison below shows, but the letters turned soft and very small print would start to blur. The fix is to remove what the reader does not need before compressing: crop away the table, the background and the margins, so the remaining pixels all go to the text. Our photo cropping guide shows how, and the cropped page above kept quality 45% where the full photo dropped to 32%.

Why Keep original size fails at 40KB
The Pixel size menu has a second option, Keep original size (no resize). It tells the tool to lower only the JPEG quality and never touch the pixel count. That is useful when a form demands the exact pixel dimensions you already prepared, but for a large photo at 40 KB it cannot work. We tried it with the same 5.00 MB phone photo: the tool went all the way down to quality 18% at the full 4000 x 3000 pixels and produced 285,869 bytes, seven times over the limit. The status line said so plainly: the image was reduced, but the target was not reached at the minimum quality.
The small 480 x 640 photo, by contrast, gave the same 31,116 byte result with either setting, because it never needed shrinking. So the rule is simple. If you must keep exact pixels, make the image small first with our resize guide, then compress it with Keep original size. Otherwise leave Shrink if needed on and let the tool find the size.

Matching what the form asks for
Small upload limits often come with extra rules about format or pixel size. Read the whole requirement before compressing, because the order of the steps matters. The table below maps common wordings to the setting to use.
| What the form says | Pixel size setting | Do this first |
|---|---|---|
| Photo under 40 KB, no pixel rule | Shrink if needed | Nothing, compress directly |
| Under 40 KB and exact pixels, for example 300 x 400 | Keep original size | Resize or crop to the exact pixels |
| Scan of a document under 40 KB | Shrink if needed | Crop to the paper edges |
| JPG only, file is PNG or WebP | Shrink if needed | Nothing; the output is always JPG |
| Between 20 KB and 50 KB | Shrink if needed | Type 48 or 50 to stay near the top |
DPI is a common source of confusion on forms with small limits. A request for 300 DPI describes print density, not file size, and you cannot convert one into the other. Our explainer on image DPI covers what forms usually mean. PNG screenshots and logos are another trap: the tool always saves JPG and fills transparent areas with white. Our PNG to JPG guide explains when that switch helps.
Check the file before you upload it
Before the upload, confirm three things: the byte count in the result box is below the limit, the file type matches what the form wants, and the image is still usable. Open the downloaded file and zoom to 100%. If a face or a line of text is too soft, try a tighter crop, or check whether the form really insists on 40 KB; some accept up to 50 or 100 KB, and the extra room makes a real difference.
If the form also sets a minimum, such as at least 20 KB, a result of 30 KB is safely inside the range. In the rare case that a file comes out too small, our guide to increasing an image size in KB covers the reverse direction. For a refresher on reading sizes in bytes, kilobytes and megabytes, see checking file size before upload.
When you are preparing several files for one application, compress them one at a time and rename each download straight away. The tool names its output after the original with -dokurapi added at the end, so originals and compressed copies stay easy to tell apart. And if one image refuses to fit even with shrinking, our note on a file that is still too big lists the remaining options.
Frequently asked questions
How do I compress an image to 40KB for free?
Why did my 40KB image get smaller in pixels?
Is 40KB the same as 40,000 bytes?
Can a document photo be compressed to 40KB?
Will a 40KB photo look blurry?
Should I use Keep original size for a 40KB target?
Is my photo uploaded to Dokurapi?
Can I compress an image to 40KB on my phone?
Sources
Need help?Result not quite right, or unsure about a form rule? Ask Dokurapi support on WhatsApp. Please do not send personal documents in chat.
Chat on WhatsApp