How JPEG compression works
JPEG is lossy, which means it permanently discards image data to make the file smaller. The encoder converts the picture from RGB into a brightness-and-colour space (YCbCr), then usually throws away half or three-quarters of the colour information outright — your eye is far more sensitive to changes in brightness than to changes in hue, so the loss is hard to see. It then splits the image into 8×8 pixel blocks and runs a discrete cosine transform over each one, which separates broad tonal shifts from fine detail. The fine detail is what gets rounded off.
The "quality" slider you see in any converter is really controlling how aggressively that rounding happens. At quality 85 a photograph is usually indistinguishable from the original at a third of the size. At quality 40 you start to see the 8×8 blocks themselves, along with a halo of noise around hard edges that engineers call mosquito noise.
Generation loss: the JPEG trap worth knowing
Every time you open a JPEG, change something, and save it again, the whole lossy pipeline runs a second time — on an image that has already been damaged once. The errors compound. A photo that has been re-saved a dozen times develops visible blocking and colour banding, and none of it can be undone.
The fix is simple: keep a lossless master. Edit from the original RAW, PNG, or TIFF, and export a JPEG only as the final step. If you need to redo the edit, go back to the master rather than to the exported JPEG. (Rotating a JPEG is a special case — some tools can rotate losslessly when the dimensions are multiples of 8 — but any tool that re-encodes will cost you quality.)
When JPG is the right choice — and when it is not
Use JPG for photographs, and especially for anything that has to work everywhere. Universal support is JPEG's real advantage: there is no device, browser, printer, or piece of software that cannot open one. If you are emailing a photo, submitting it to a form, or handing it to software of unknown vintage, JPEG is the safe answer.
Avoid JPG for images with hard edges and flat colour — screenshots, logos, diagrams, text, line art, pixel art. The block-based transform smears across sharp transitions, so a screenshot saved as JPEG looks smudged and is often larger than the same screenshot as PNG. Avoid it too whenever you need transparency: JPEG has no alpha channel at all, so a transparent PNG saved as JPEG comes back with a solid background filled in.
Converting JPG files
Converting a JPG to PNG will not restore detail that compression already discarded — it simply stops any further loss, at the cost of a much larger file. It is worth doing when you are about to start editing, and rarely worth doing otherwise.
Converting to WebP or AVIF is a different proposition: both reach the same perceived quality as JPEG at roughly 25–50% smaller file size, which is why they have taken over web delivery. The trade-off is compatibility with older software, so keep the JPEG if the file has to travel widely.