How JPG Compression Works
JPG (also written JPEG, after the Joint Photographic Experts Group that created it) is the world's most common image format, and it earned that place by being extremely good at one thing: making photographs small. It does this through lossy compression, deliberately discarding image detail that the human eye is unlikely to notice in order to dramatically shrink the file. A photo saved as JPG is often a tenth the size of the same image as PNG, with no visible difference at sensible quality settings.
The compression exploits the limits of human vision. It works by converting the image into frequency information (using a mathematical operation called the discrete cosine transform), then throwing away the high-frequency detail our eyes are least sensitive to, particularly fine color variation, since people notice changes in brightness far more than changes in color. The remaining data is then packed efficiently. This is why JPG is brilliant for photos, which are full of smooth gradients and subtle tones, and poor for sharp-edged graphics, where discarding high-frequency detail produces visible smearing.
A quality setting (typically 0 to 100) controls how aggressively JPG discards data. At high quality (around 85 to 95) the loss is invisible; as you lower it, the file shrinks further but artifacts appear: blocky 8x8 squares, halos around sharp edges, and a general softening. The practical sweet spot for most photos is 80 to 90, small files with no obvious degradation.
The Generation Loss Trap
The single most important thing to understand about JPG is that its loss is permanent and cumulative. Every time you open a JPG, edit it, and save it again as JPG, the lossy compression runs again and discards a little more detail, a problem called generation loss. Save the same JPG a dozen times and it visibly degrades, even at high quality. This is why JPG should be a final delivery format, not a working format. For editing, keep a lossless master (PNG, TIFF, or your camera's RAW file) and export a fresh JPG each time, rather than repeatedly re-saving the same JPG.
History and Variants
The JPEG standard was published in 1992 and quickly became the default for digital photography and the web, a position it has held for three decades thanks to universal support and excellent compression of photographic content. The .jpg and .jpeg extensions refer to the same format; the shorter .jpg exists because older Windows systems limited extensions to three characters.
JPG also defines a progressive mode, where the image loads as a low-resolution version that sharpens as more data arrives, useful on slow connections. JPG files usually carry rich EXIF metadata, the camera settings, date, and GPS location embedded by digital cameras and phones, which is one reason it remains the standard for photography. Newer formats like WebP and AVIF compress better, but none has displaced JPG's universal compatibility.
JPG vs PNG vs WebP
The rule of thumb is simple. Use JPG for photographs and any image that is mostly smooth tones and gradients. Use PNG for screenshots, logos, text, line art, and transparency, where JPG's lossy compression would smear sharp edges and where you need a transparent background (which JPG cannot do at all). For the web, WebP is the modern upgrade: it compresses photos smaller than JPG at the same quality and adds transparency, so where browser support allows it can replace JPG with smaller files. JPG's enduring advantage is that it works absolutely everywhere, with no compatibility questions.