JPEG XL (JXL)
| Full name | JPEG XL |
|---|---|
| Extensions | .jxl |
| MIME type | image/jxl |
| Type | raster image, lossy and lossless compression, animation |
| Starts with | FF 0A (bare codestream) or 00 00 00 0C 4A 58 4C 20 0D 0A 87 0A (container) |
| Specification | ISO/IEC 18181-1:2024 (codestream), ISO/IEC 18181-2 (file format) |
| Maintained by | ISO/IEC JTC 1/SC 29 (JPEG committee) |
| Reference implementation | libjxl (BSD-3-Clause) |
| License | open, royalty-free |
JPEG XL is a still-image format that covers what JPEG, PNG and GIF do in one file type: lossy compression for photos, lossless compression for graphics, alpha transparency, animation, up to 32-bit float samples, HDR, wide color gamut and progressive decoding. At the same visual quality a lossy JPEG XL file is usually 30-60% smaller than a JPEG.
Its special feature is lossless JPEG recompression: an existing JPEG file can be converted to JPEG XL about 20% smaller, and the original JPEG can be rebuilt from it bit for bit. That makes it a good format for archiving photo collections without any quality loss.
When to use JPEG XL#
- Use for photo archives: recompress existing JPEGs losslessly and get back the exact original files when needed.
- Use for high-quality photos, HDR and wide-gamut images, and images with high bit depth (16-bit, float) from cameras and scanners.
- Use as a lossless format that is usually smaller than PNG and much faster to encode than optimized PNG.
- Use for very large images: dimensions go up to about 1 billion pixels per side, and decoders can decode a region or a low-resolution preview.
- Avoid on the web when every visitor must see the image without a fallback: check current browser support first and serve JPEG, WebP or AVIF as a fallback with
<picture>. - Avoid when you need to send files to people with older systems: Windows 10, older macOS and many apps can’t open JXL.
File structure#
A JPEG XL file is either a bare codestream or a container that wraps the codestream in ISOBMFF boxes (the same box format as MP4, HEIF and AVIF).
Bare codestream#
The file starts with FF 0A, followed by a bit-packed header. There are no byte-aligned fields to read in a hex editor after the signature: use a decoder or jxlinfo to see the header.
FF 0A codestream signature
xx xx ... SizeHeader (width, height), ImageMetadata, then frames
A bare codestream is the smallest form. It can hold the image, color space (as an enum or ICC profile), orientation, animation and extra channels, but no Exif or XMP.
Container#
The container is used when the file has Exif, XMP or JUMBF metadata, JPEG reconstruction data, or a frame index for seeking in animations.
00 00 00 0C 4A 58 4C 20 0D 0A 87 0A box size 12, type "JXL ", signature
00 00 00 14 66 74 79 70 6A 78 6C 20 00 00 00 00
6A 78 6C 20 box size 20, "ftyp", brand "jxl ", version 0, compatible "jxl "
xx xx xx xx 6A 78 6C 63 FF 0A ... "jxlc" box: the whole codestream
Each box is a 4-byte big-endian size, a 4-byte type and the data (a size of 1 means a 64-bit size follows, 0 means “to the end of the file”).
| Box | Purpose |
|---|---|
JXL |
signature, always first, 12 bytes |
ftyp |
file type, brand jxl |
jxll |
codestream level: 5 (default, for most uses) or 10 (larger images, more channels, higher precision) |
jxlc |
the codestream in one box |
jxlp |
the codestream split into parts, so metadata can be placed between parts |
jbrd |
JPEG bitstream reconstruction data: rebuilds the original JPEG file exactly |
Exif |
Exif metadata (4-byte offset, then TIFF header) |
xml |
XMP metadata |
jumb |
JUMBF metadata (e.g. C2PA content credentials) |
brob |
another box compressed with Brotli (e.g. compressed Exif or XMP) |
jxli |
frame index for seeking in animations |
Inside the codestream#
The codestream has a header, then one or more frames. Each frame uses one of 2 modes:
| Mode | Used for | How it works |
|---|---|---|
| VarDCT | lossy photos, recompressed JPEGs | DCT with variable block sizes from 2x2 to 256x256 in the XYB color space (a perceptual space). A recompressed JPEG uses only 8x8 blocks, keeping the original DCT coefficients |
| Modular | lossless, graphics, extra channels | integer-only prediction with a context tree (MA tree), reversible color transforms, palettes and the Squeeze transform for progressive decoding |
Other coding tools: patches (copy repeated content like text glyphs from a reference frame), splines (smooth curves drawn over the image), noise synthesis (adds film grain at decode time instead of storing it), and two decoder filters (Gaborish and an edge-preserving filter) that reduce blocking and ringing.
The image is split into groups of 256x256 pixels (VarDCT) or 128 to 1024 pixels (Modular), plus a low-resolution 1:8 image (LF) in groups covering 2048x2048 pixels. A table of contents gives the offset of each group, so decoders can decode in parallel, decode only a region, or show a preview from the first bytes of the file.
Limits#
| Property | Value |
|---|---|
| Width, height | 1 to 1,073,741,823 (230-1) pixels; level 5 allows up to 262,144 per side and 228 pixels in total |
| Channels | gray or RGB, plus extra channels (alpha, depth, spot colors, CMYK black): up to 4 at level 5, up to 4096 at level 10 |
| Bit depth | up to 16 bits per sample at level 5; higher integer precision and 32-bit float at level 10 |
| Animation | yes, with frame durations, blending and layers |
Lossless JPEG recompression#
cjxl photo.jpg photo.jxl # lossless JPEG transcoding is the default for JPEG input
djxl photo.jxl restored.jpg # bit-identical to photo.jpg
cjxl photo.png photo.jxl -d 1 # lossy: distance 1 is visually lossless (default for PNG input)
cjxl photo.png photo.jxl -d 0 # lossless
cjxl photo.png photo.jxl -q 90 -e 7 # quality on a JPEG-like scale, effort 1-10
cjxl, djxl and jxlinfo come with libjxl. The -d (distance) option sets the maximum visual error: 0 is lossless, 1 is visually lossless, 2-3 is good quality for the web. Higher effort (-e) makes smaller files but encodes slower.
Specifications and documentation#
- ISO/IEC 18181-1:2024: core coding system (the codestream), paid
- ISO/IEC 18181-2: file format (the container and metadata boxes), paid
- JPEG XL overview at jpeg.org: official page of the JPEG committee
- JPEG XL format overview: free technical summary of the format from the libjxl authors
- libjxl API documentation
- jpegxl.info: community site with comparisons, software lists and a browser test page
- Conformance test files
- JPEG XL on Wikipedia
- Browser support on caniuse
Software that opens JPEG XL files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; also opens JXL inside archives and comic books | |||
| Web browsers | ✓ | ✓ | ✓ | view | Safari 17+ (partial), recent Chrome and Firefox; check caniuse for current versions. Also on Android and iOS | |
| JPEG XL Image Extension | ✓ | view | free from Microsoft, Windows 11 24H2+; adds JXL to File Explorer thumbnails and Photos | |||
| macOS Preview | ✓ | view, convert | built into macOS 14 and later | |||
| GIMP | ✓ | ✓ | ✓ | view, edit, create, convert | free, open source | |
| Krita | ✓ | ✓ | ✓ | view, edit, create | free, open source; animation and HDR | |
| darktable | ✓ | ✓ | ✓ | view, edit, convert | free, open source raw photo editor, JXL import and export | |
| digiKam | ✓ | ✓ | ✓ | view, convert | free, open source photo manager | |
| XnView MP | ✓ | ✓ | ✓ | view, convert | free for private use | |
| IrfanView | ✓ | view, convert | free for non-commercial use, needs the plugins pack | |||
| ImageMagick | ✓ | ✓ | ✓ | convert, create | command line, open source | |
| libjxl tools | ✓ | ✓ | ✓ | convert, create | cjxl, djxl, jxlinfo: reference encoder and decoder | |
| Squoosh | ✓ | convert | encode JXL in the browser | |||
| FFmpeg | ✓ | ✓ | ✓ | convert | when built with libjxl, reads and writes JXL images and animations |
Libraries#
Open-source libraries that read and write JPEG XL. See all JPEG XL libraries for a comparison.
| C/C++ | libjxl |
|---|---|
| C# | Magick.NET |
| Java | JXLatte |
| Go | gen2brain/jpegxl |
| Python | pillow-jxl-plugin, pyvips |
| Ruby | ruby-vips |
| Rust | jpegxl-rs, jxl-oxide |
| PHP | Imagick |
Related formats#
- JPEG: the format JPEG XL can recompress losslessly; supported everywhere
- AVIF: AV1-based, better at very low bitrates, wider browser support, no lossless JPEG recompression
- HEIC: HEVC-based format used by iPhones; patent-encumbered
- WebP: older web format, limited to 8-bit and 16383 x 16383 pixels
- PNG: lossless, universally supported, usually larger than lossless JPEG XL
- JPEG 2000: older wavelet format used in archives and medical imaging