
What Is JPEG XL? Recovering the Original JPEG and Serving Images on the Web
Could you shrink a collection of JPEG photos and still get each original file back? For compatible JPEG inputs, JPEG XL can do exactly that: it can reconstruct a JPEG whose bytes match the original file.
Delivering images on the web raises different questions, including which browsers decode JXL and what they should load when the format is unsupported. A round-trip test on a Mac helps show when each approach makes sense.
Japanese original published: 2026-11-26
Two meanings of lossless
JPEG XL is the image coding system and file format standardized as ISO/IEC 18181. It supports lossy and lossless compression, HDR, high bit depths, transparency, animation, and progressive decoding. Files generally use the .jxl extension.
Pixel-lossless compression preserves the pixel values supplied to the encoder. If those pixels came from decoding a PNG, preserving them does not promise to reproduce the PNG's metadata or byte layout.
Lossless transcoding of an existing JPEG can preserve the original file itself. Decoding to pixels and saving those pixels in another format does not provide that guarantee. If you need to archive the JPEG you received, verify byte-for-byte reconstruction rather than judging a new export by appearance.
How JPEG XL stores enough information to rebuild a JPEG
Conventional JPEG divides the image into blocks and uses a discrete cosine transform (DCT) to express changes in brightness and color as frequency components. Quantization rounds those coefficients. Information discarded at this step cannot be recovered by switching formats.
For compatible JPEGs, the lossless transcode reads the already quantized coefficients and encodes them in a different way without quantizing them again. The coefficients are carried in the JPEG XL codestream. Reconstruction combines them with data in the jbrd box and any applicable metadata boxes, such as EXIF. An ordinary JXL image without the required reconstruction data can be exported to JPEG, but that export does not establish recovery of the original file.
Figure 1. From the original JPEG to a byte-identical copy
- Original JPEG. Start with the file produced by a camera or editor.
- Transcode to JPEG XL. Encode the existing coefficients and store reconstruction data.
- Reconstruct the JPEG. Use the stored data to rebuild the original byte sequence.
- Compare the files. Check that every byte matches the original.
Recompression can save space when the same information has a more compact representation. The cost of metadata and reconstruction information still matters. This process recovers the input JPEG, with the limitations already present in that file, rather than the camera's raw capture.
How much smaller were the three test files?
We used libjxl 0.12.0 on an Apple silicon Mac. With Pillow 11.3.0, we saved the same crop of a generated image as baseline and progressive JPEG, both with Pillow’s JPEG quality setting of 85 and 4:2:0 chroma subsampling and a simple EXIF description tag. A third sample used a separate grid-and-shapes image at the same quality and chroma settings, with JPEG optimization enabled. All three files were 800 × 600 pixels.
cjxl original.jpg archived.jxl --lossless_jpeg=1 --effort=7
djxl archived.jxl restored.jpg
cmp original.jpg restored.jpg
shasum -a 256 original.jpg restored.jpgFor reconstruction, we used a .jpg output name and checked the decoder log to confirm that it ran in JPEG reconstruction mode. All three round trips matched the original bytes and SHA-256 hashes. As a control, we decoded the baseline JPEG to pixels and compressed those pixels losslessly. Exporting that JXL to .jpg encoded a new JPEG, with a different hash. The output extension and visual appearance alone cannot distinguish the two paths.
Figure 2. File size before and after lossless transcoding
Shared scale for all samples: 0 to 81,528 B.
Photo-like image (baseline) (15.8% smaller)
Original JPEG · 81,528 B
JPEG XL · 68,637 B
Same image (progressive) (12.3% smaller)
Original JPEG · 78,186 B
JPEG XL · 68,568 B
Graphic (optimized baseline) (50.4% smaller)
Original JPEG · 31,487 B
JPEG XL · 15,612 B
The two encodings of the same photo-like image started at different sizes. The roughly 50% reduction for the graphic applies to that fixture and those settings. The three files cover only two distinct images and do not establish typical savings for camera originals or relative visual quality against WebP or AVIF.
Choosing a format for archiving, web delivery, or sharing
Scroll horizontally if the table does not fit.
| Use case | Approach | What to check |
|---|---|---|
| Archive JPEG originals | Transcode losslessly and reconstruct JPEGs when needed. | Byte equality, the original hash, and an independent backup. |
| Deliver photos on the web | Test target devices and offer JXL with a fallback where appropriate. | Decoding, transfer size, time to first display, and processing and storage costs. |
| Submit or share images | Use a format the recipient accepts. | Accepted extensions, recompression, and metadata handling. |
Editorial comparison based on format and browser documentation: JPEG Committee: JPEG XL · WebKit: WebKit Features in Safari 17.0
For archiving, test the full round trip first, then record the original hash and codec version. A hash helps check integrity; keep a separate backup as well. If a file cannot be converted, fails verification, or grows in size, keep the original JPEG.
When sharing images, check the actual file you plan to send. If the original JPEG contains location data, reconstructing the original can restore it as well. Our EXIF test used a description tag. For a public copy, retain only the metadata you intend to share.
Check browser support before serving JXL
In official documentation checked on November 26, 2026, Chrome introduced JPEG XL decoding in version 155, Firefox enabled it by default in 158, and WebKit announced support in Safari 17. These are vendor-reported starting points. Test still images, progressive display, and animation separately where you need those features. Also verify whether your editing tools can open and export the format. Chrome's support does not establish support in every Chromium-based product.
For web delivery, prepare a JXL file and a fallback. In a picture element, a source with type="image/jxl" lets the browser select JXL when it recognizes the format. The final img supplies a fallback URL and the alternative text for either selected image.
<picture>
<source srcset="/images/lake.jxl" type="image/jxl">
<img src="/images/lake.jpg" width="800" height="600"
alt="A lake reflecting the sunrise and a mountain">
</picture>Format selection does not guarantee that a broken JXL URL will fall back to JPEG. Test both URLs, Content-Type, and what the browser actually selects and decodes. If you use one URL and negotiate via HTTP Accept, check Vary: Accept and the CDN cache key so responses with different formats stay separate.
For a migration decision, test images at the same display dimensions and comparable visual quality. Measure the size transferred, time to first display, and decoding cost under realistic delivery conditions. Estimate how often the fallback is selected as well. The archiving experiment measures file size under exact JPEG reconstruction, so it cannot establish a speed-up for your site.
References and sources
- JPEG Committee: JPEG XL ↗(Overview of ISO/IEC 18181, lossless JPEG recompression, and progressive coding.)
- JPEG Committee: JPEG White Paper: JPEG XL image coding system ↗(White Paper 2.0. Recompression, coding features, and quality measurement conditions.)
- GitHub: libjxl/libjxl: JPEG XL image format reference implementation ↗(Reference implementation and the cjxl and djxl reconstruction workflow.)
- libjxl documentation: Decoder API - jxl/decode.h ↗(JPEG reconstruction events, the jbrd box, the codestream, and metadata boxes.)
- WHATWG: HTML Standard ↗(Sections 4.8.1 and 4.8.2. The picture element and source type selection.)
- RFC Editor: RFC 9110: HTTP Semantics ↗(Section 12.5.5. Vary and cache handling for responses selected by request headers.)
- Chrome for Developers: Shipping JPEG XL in Chrome ↗(October 6, 2026. Chrome 155 decoding and adoption of jxl-rs.)
- Mozilla: Firefox 158 release notes for developers ↗(Default JPEG XL decoding in Firefox 158 and the change to the image Accept header.)
- WebKit: WebKit Features in Safari 17.0 ↗(Safari 17 support and format selection with picture.)
Editorial note
This article was prepared with AI assistance and reviewed by an editor before publication. It may still contain factual errors, interpretation mistakes, or outdated information. Check the cited primary sources or official documentation before making an important decision.

