This is a reference for the file format of jpeg2000 files. Not everything is specified here, unfortunately you would need the purchase the ISO standard or read source code for everything. But I’ll accept edits if you want to add anything here.

JPEG 2000 files (extension .jp2 or .jpx) are constructed via a series of structures called Boxes.


A box is a structure made up of 3 (or 4) fields. All integer values are big-endian.

struct Box {
  length: u32;
  type: char[4];
  // Only preset if length == 1.
  (xl_length): u64;
  contents: u8[length];

xl_length is only present if length == 1. In that case, the actual length of contents is xl_length.

There are many types of boxes. The standard defines what the box contents are based on the type field. Some boxes are superboxes, meaning that the contents are just more boxes.

The most comprehensive list of boxes I’ve found outside the standards live in the glymur source code

JPEG2000 Signature

This is a required box. And will be the first box in a jpeg2000 file.

struct SignatureBox {
  length = 12;
  type = "jP  " (jP followed by 2 spaces);
  contents = (there is a magic number here, but the above section is enough)