JPEG File Header and Marker Structure

A JPEG interchange stream begins with the Start of Image marker and ends with End of Image. Between them, marker segments describe tables, frames, scans, and optional metadata.

JPEG Start of Image marker

FF D8 FF

The actual SOI marker is FF D8 at offset 0. It is normally followed by another marker prefix byte FF, which produces the common three-byte file signature shown above.

Common JPEG markers

MarkerNamePurpose
FF D8SOIStart of Image
FF E0APP0Often carries a JFIF identifier and density fields
FF E1APP1Often carries Exif or XMP metadata
FF DBDQTQuantization table definition
FF C0SOF0Baseline DCT frame header
FF C2SOF2Progressive DCT frame header
FF C4DHTHuffman table definition
FF DASOSStart of Scan
FF D9EOIEnd of Image

Variable-length marker segments

Most markers that carry parameters are followed by a two-byte big-endian segment length. That length includes the two length bytes themselves but not the marker. Offsets after SOI are therefore not globally fixed.

Entropy-coded scan data follows SOS. Inside that data, FF 00 represents a stuffed literal FF byte, so a raw search for FF is not enough to parse scan boundaries correctly.

Practical JPEG inspection checks

  • Confirm SOI at the beginning and EOI near the end.
  • Read each parameter segment length as big-endian before advancing.
  • Distinguish APP0/JFIF and APP1/Exif metadata rather than assuming one is always present.
  • Use SOF0 or SOF2 to find image precision, height, width, and component information.
  • Use a JPEG-aware parser for full entropy-stream and table validation.

Local processing and privacy

The JPEG file format workflow opens the same Bitpeek browser workspace. Selected file bytes, file names, pasted input, searches, edits, hashes, and comparison data are processed in local browser memory and are not sent to a Bitpeek server.

The static guide itself can be read without opening a file or creating an account.

Technical reference: ITU-T Recommendation T.81 — JPEG interchange format.

Frequently asked questions

Why is the common JPEG signature three bytes if SOI is two?

SOI is FF D8. A valid interchange stream continues with another marker, whose prefix is FF, so file-signature tables commonly use FF D8 FF.

Is Exif always present in a JPEG?

No. Exif commonly appears in an APP1 segment, but JPEG files can omit it or use APP1 for other identified payloads such as XMP.

Are JPEG segment offsets fixed?

No. Segment lengths and optional metadata determine later offsets. Parse the two-byte length of each applicable marker segment.