Every time you save a JPG, it gets a little worse.
JPG makes photos small by throwing away detail your eye barely notices. Open it, edit it, save it again, and it throws away a little more. Your browser is re-saving the image below right now, as many times as you choose.
The encoder cuts the picture into 8-pixel squares and describes each one as a mix of simple wave patterns, keeping the strong ones and rounding off the faint ones. At low quality the squares stop matching their neighbours, and sharp edges get a halo of ripples.
JPG assumes smooth, natural pictures. Give it hard edges, flat colour or a need for see-through areas and a different format wins.
Everything a developer or archivist needs to identify, handle and validate a JPEG file, in one place.
A JPEG file is a sequence of segments. Each begins with a two-byte marker, then its own length. This is the layout of a typical phone photo; click a segment to see what it holds and why it matters.
FF D8
This page walks the file marker by marker. It works out the quality setting from the quantisation tables, reads the frame header for chroma subsampling, and decodes EXIF, XMP, IPTC and ICC data. It also pulls out the embedded thumbnail and checks it still matches the photo. Then it builds a copy with the metadata stripped, without re-encoding a single block. Everything happens on your device. Both samples are real JPGs built in your browser; the second is broken on purpose.
The committee kept designing successors. Each is technically better; none has replaced the 1992 original, because nothing beats universal support.
Converting out of JPG stops further loss, but can't bring back what's already gone.