Content encoding

None of the encodings listed are involved with patent concerns.

Usage Encoding Extension
Rasterized image JPEG XL .jxl
WebP .webp
AVIF .avif
Vector image SVG .svg
Lossy audio Opus .opus
Vorbis .ogg
AAC-LC .m4a .aac
Lossless audio WavPack .wv
FLAC .flac
Web compression Brotli .br
gzip .gz
Bundle compression lzip .lz .tlz
bzip2 .bz2 .tbz2
xz .xz .txz
Font WOFF2 .woff2

Read below for further details.

Rasterized image encoding


As WebP is properly supported in every browser built for systems newer than Windows XP, and it offers better quality-to-size ratio than all JPEG encoders, it is considered the best fallback format. However, as JPEG XL exists as an all-around better universal image format, lossy images should also be encoded with JPEG XL whenever possible.

Compared to all other image formats, JPEG XL offers jawdropping image fidelity, unmatched quality-to-size ratio, proper progressive loading and better responsiveness. The cherry on top of JPEG XL would be its ability to losslessly transcode from existing JPEG files, offering about 20% size reduction with cheap JPEG lossless bitstream reconstruction, which paves its way to be a backwards-compatible drop-in replacement for image storage and distribution.

mozJPEG-fronted JPEG, while offering a good choice for backwards-compatibility, shouldn't be used unless necessary when size is a consideration. AVIF should be avoided for lossy encoding.

Codec Use Params
JPEG XL Delivery cjxl -d 2 -e 4 -p
Archival cjxl -d 1 -e 4 -p
WebP Delivery (perception) cwebp -m 5 -psnr 56 -qrange 90 95
Delivery (fast-encode) cwebp -m 5 -q 95
Archival cwebp -m 5 -q 99

The full feature set comparison chart is available on Cloudinary.

Battle of the image codecs!


AVIF is the current best solution for lossless image encoding, with JPEG XL tailing behind. If size is the bigger factor, choose AVIF lossless. If compatibility is a concern, choose WebP lossless. JPEG XL in its current state doesn't offer much advantage against AVIF.

Do not enable progressive encoding for JPEG XL lossless, or the resulting file will be several times bigger than PNG files.

Audio encoding


When high sampling rates are required, choose Vorbis. When support for the Apple ecosystem is required, choose AAC-LC. Otherwise use Opus under all possible scenarios, but beware that Opus only supports sampling at 48kHz.

Below are the suggested bitrates under different scenarios, when encoding stereo audio content under either 44.1kHz or 48kHz. Audio content should be encoded with constrained variable bitrate (CVBR).

The AAC-LC encoder in question is libfdk_aac, being the best FOSS AAC-LC encoder out there. The only AAC-LC encoder better than libfdk_aac is Apple's Audio Toolbox, which is proprietary and not in consideration.


Keep in mind that the scenario under "basic" indicates that, all audio content encoded with provided parameters should be virtually indistinguishable from LAME-encoded MP3 files at 192kbps.


Streaming lossless audio is generally considered a bad idea due to high bandwidth usage. It's generally more useful for archival purposes.

You should choose FLAC when...

  • Browser support is needed.
  • The target is severely underpowered.
  • The target only supports FLAC for lossless audio compression.

You should choose WavPack when...

  • You need a smaller file.
  • Higher bit depth is needed (more than 24).
WavPackwavpack -hhvx -x 3
FLACflac -V8 -e --no-padding -f



Brotli should be preferred over gzip at all times. Static low-entropy content (e.g. plain text files) should always be pre-compressed, with or without the original uncompressed file available.

For static precompression, the original file can be omitted when the space is constrained, serving only precompressed blobs. When compatibility with other infrastructure isn't in consideration, precompressed gzip files can also be omitted, although it's not recommended in most cases.

Algorithm Use Params
Brotli Real-time brotli -4
Precompression brotli -q 11
gzip Real-time gzip -4
Precompression zopfli --i25


lzip is the de-facto standard of bundle compression, featuring good compression ratio with data recovery abilities. Quality should always set to 9, unless a lower quality value is proven to yield a better result for smaller files, or time constraints are set.

bzip2 or xz should only be considered for compatibility purposes.


As practically all modern browsers support the WOFF2 font format, all required TrueType and OpenType fonts must be served as WOFF2 files instead. If for unspecified reasons that original files must be served, always consider precompression and avoid storing uncompressed files.