Image

How to compress an image to 40KB without losing the important detail

At 40 KB a big phone photo cannot fit on quality alone, so the tool also shrinks the pixels. Here are the steps, the 20 attempts it made on one photo, and the real results for five test images.

Updated ยท 11 min read

Featured image: How to compress an image to 40KB without losing the important detail, with a real screenshot of the Compress Image tool tool on Dokurapi
Inside the frame: a real screenshot of the Dokurapi tool. All processing runs in the browser, nothing is uploaded.

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
Dokurapi Compress Image tool with 40 typed as the custom target, showing a 5.00 MB phone photo reduced to 30.8 KB at quality 32% and 1474 x 1106 px
The live tool after our first test: a synthetic 5.00 MB phone photo with 40 in Custom target (KB) and Pixel size on Shrink if needed. The safe target was reached at 30.8 KB, quality 32%, with the longest side reduced to 1,474 pixels.

Ready to try it? The tool is free and runs in your browser.

Open the Compress Image tool

How 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.

Line chart of the 20 attempts on a 5.00 MB phone photo: eight quality steps at 2400 px from 971,942 to 60,271 bytes, then rounds at 2040, 1734 and 1474 px, ending at 30,836 bytes under the 37,600 byte safe line
Every attempt the tool made on our phone photo with a 40 KB target, on a logarithmic size scale. Lowering quality alone stopped at 60,271 bytes, so the tool started shrinking the pixels; each new round jumps back up at quality 72% and comes down again. Attempt 20 fitted.

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.

Compress image to 40KB: results on five test images (26 November 2026)
Test imageOriginalResultQuality and pixelsWhat happened
Signature scan278 KB, 1600 x 60029,772 B34%, 1600 x 600Quality only, sixth step
Small photo140 KB, 480 x 64031,116 B44%, 480 x 640Quality only, fifth step
Phone photo5.00 MB, 4000 x 300030,836 B32%, 1474 x 1106Three pixel rounds, 20 attempts
Cropped document682 KB, 1500 x 100031,839 B45%, 723 x 482Four pixel rounds
Document photo5.27 MB, 3000 x 400034,000 B32%, 604 x 805Three 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.

Five green bars under a dashed 37,600 byte safe line: signature scan 29,772, small photo 31,116, phone photo 30,836, cropped document 31,839 and document photo 34,000
All five results against the 37,600 byte safe line. Every image fitted, with between 3,600 and 7,800 bytes to spare. The document photo came closest because fine text is the hardest content to squeeze.

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.

The same five images at 20KB, 40KB and 50KB targets
Test image20 KB target40 KB target50 KB target
Signature scan18,325 B at 18%, 1600 x 60029,772 B at 34%, 1600 x 60042,340 B at 44%, 1600 x 600
Small photo16,261 B at 24%, 480 x 64031,116 B at 44%, 480 x 64045,971 B at 64%, 480 x 640
Phone photo18,726 B at 32%, 1065 x 79930,836 B at 32%, 1474 x 110642,406 B at 32%, 1734 x 1301
Cropped documentNot reached: 20,656 B at 640 x 42831,839 B at 45%, 723 x 48237,417 B at 32%, 783 x 523
Document photoNot reached: 24,351 B at 479 x 64034,000 B at 32%, 604 x 80543,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%.

Side by side crop of the same printed lines from the 5.27 MB document photo and from the 34.0 KB result at 604 x 805 px, the result softer but still readable
The same patch of our document photo before (5.27 MB, 3000 x 4000 px) and after compressing to 40 KB (34.0 KB, 604 x 805 px, quality 32%), scaled to the same width. The words remain readable, but the strokes are visibly softer.

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.

Dokurapi Compress Image tool with Keep original size selected, showing a 5.00 MB phone photo reduced only to 286 KB at quality 18% and 4000 x 3000 px, with a message that the target was not reached
With Keep original size selected, the same phone photo stopped at 286 KB: quality 18% at the full 4000 x 3000 pixels is the lowest the tool goes, and it reports that the 40 KB target was not reached.

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.

Which setting to use for common 40KB requests
What the form saysPixel size settingDo this first
Photo under 40 KB, no pixel ruleShrink if neededNothing, compress directly
Under 40 KB and exact pixels, for example 300 x 400Keep original sizeResize or crop to the exact pixels
Scan of a document under 40 KBShrink if neededCrop to the paper edges
JPG only, file is PNG or WebPShrink if neededNothing; the output is always JPG
Between 20 KB and 50 KBShrink if neededType 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?
Open the Dokurapi Compress Image tool, choose the image, type 40 in the Custom target (KB) box, keep Pixel size on Shrink if needed, press Compress photo and download the result. It is free, needs no account, and the image stays in your browser.
Why did my 40KB image get smaller in pixels?
A large photo cannot reach 40 KB on quality alone. In our test a 5 MB phone photo was still 60,271 bytes at quality 18%, so the tool reduced the pixels in three rounds until it fitted at 1474 x 1106 px.
Is 40KB the same as 40,000 bytes?
In decimal units, yes. Systems that use 1,024 count 40 KB as 40,960 bytes. The tool aims at 37,600 bytes so the file passes either way.
Can a document photo be compressed to 40KB?
In our test, yes. A 5.27 MB photo of a printed page fitted at 34,000 bytes and 604 x 805 px, still readable. Cropping to the paper edges first keeps more detail.
Will a 40KB photo look blurry?
It looks softer than the original but usually clear enough for a form. Our phone photo kept 1,474 pixels on the long side at quality 32%, and the small portrait kept quality 44%.
Should I use Keep original size for a 40KB target?
Only if the image is already small in pixels. With Keep original size our 5 MB phone photo stopped at 286 KB at quality 18%, far above the target.
Is my photo uploaded to Dokurapi?
No. The image is read and compressed by your browser on your own device and is never sent to a server.
Can I compress an image to 40KB on my phone?
Yes. The tool runs in mobile browsers such as Chrome and Safari, and you can pick the photo straight from your gallery.

Sources

  1. Prefixes for binary multiples, NIST
  2. HTMLCanvasElement: toBlob() method, MDN Web Docs

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

Related articles

Try Dokurapi for Free

No account needed. Pick a tool, drop in a file, and download the result, free.