lz4/lz4 logo

lz4/lz4

Free

Extremely Fast Compression algorithm

FreeFree tier
Type
Open Source

About lz4/lz4

LZ4 is a lossless compression algorithm known for its extremely high compression and decompression speeds. It achieves compression speeds of 500 MB/s per core, scaling efficiently with multi-core CPUs, and decompression speeds in multiple GB/s per core, often reaching RAM speed limits. The speed can be dynamically tuned via an 'acceleration' factor, trading compression ratio for faster operation. A high compression variant, LZ4_HC, is also available, offering improved compression ratios at the cost of slower compression while maintaining the same decompression speed. LZ4 supports dictionary compression, both at API and CLI levels, and can be combined with the Zstandard Dictionary Builder for better performance on small files. The library is provided as open-source software under the BSD 2-Clause license and includes a reference implementation in C, with numerous ports in other languages. Benchmarks show LZ4 outperforms many popular compressors (e.g., Snappy, LZO, zlib) in speed while maintaining reasonable compression ratios.

Key Features

Compression speed 500 MB/s per core
Decompression speed multiple GB/s per core
Scalable with multi-core CPUs
Tunable acceleration factor for speed/ratio trade-off
High compression derivative LZ4_HC
Dictionary compression support
Streaming and frame format support
Open-source under BSD 2-Clause license

Pros & Cons

Pros
  • Extremely fast compression and decompression
  • Multi-core scalability
  • Very high decompression speed near RAM limits
  • Small code footprint
  • Wide language support and portability
Cons
  • Compression ratio is moderate compared to high-compression algorithms like zstd or lzma
  • No built-in encryption or error recovery

Best For

General-purpose file compressionData storage and archivalNetwork data transferReal-time applications requiring low latencyEmbedded systems with limited resources

FAQ

What is LZ4?
LZ4 is a lossless compression algorithm that prioritizes extremely high compression and decompression speeds.
How fast is LZ4?
LZ4 provides compression speeds of 500 MB/s per core and decompression speeds in multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.
Is LZ4 open source?
Yes, LZ4 is open-source software released under the BSD 2-Clause license.
What is LZ4_HC?
LZ4_HC is a high compression derivative of LZ4 that trades CPU time for improved compression ratio while maintaining the same decompression speed.
Does LZ4 support dictionary compression?
Yes, LZ4 supports dictionary compression at both API and CLI levels, using the final 64KB of any input file as a dictionary.