<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Compression",
  "identifier" : "/documentation/Compression/COMPRESSION_LZFSE",
  "metadataVersion" : "0.1.0",
  "role" : "Global Variable",
  "symbol" : {
    "kind" : "Global Variable",
    "modules" : [
      "Compression"
    ],
    "preciseIdentifier" : "c:@EA@compression_algorithm@COMPRESSION_LZFSE"
  },
  "title" : "COMPRESSION_LZFSE"
}
-->

# COMPRESSION_LZFSE

The LZFSE compression algorithm, which is recommended for use on Apple platforms.

```
var COMPRESSION_LZFSE: compression_algorithm { get }
```

## Discussion

LZFSE is the Apple proprietary, general-purpose compression algorithm. It pairs an LZ77-style match finder with Finite State Entropy (FSE, a variant of tabled Asymmetric Numeral Systems) to encode literals and match metadata, which lets it match the compression ratio of [`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB) (zlib level 5) while running 2x to 3x faster for both encoding and decoding. LZFSE is also substantially more energy-efficient than [`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB), which makes it a good default for mobile and battery-powered devices.

LZFSE sits at a balanced point in the speed-ratio tradeoff: it compresses better than [`COMPRESSION_LZ4`](/documentation/Compression/COMPRESSION_LZ4) and runs faster than [`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB) or [`COMPRESSION_LZMA`](/documentation/Compression/COMPRESSION_LZMA), but doesn’t match the ratio of [`COMPRESSION_LZMA`](/documentation/Compression/COMPRESSION_LZMA) or the raw throughput of [`COMPRESSION_LZ4`](/documentation/Compression/COMPRESSION_LZ4). For new Apple-only code, prefer [`COMPRESSION_LZMESH`](/documentation/Compression/COMPRESSION_LZMESH) — it typically compresses a bit better than LZFSE, encodes significantly faster, and decodes slightly faster.

If a payload needs to be decoded on another platform such as Linux or Windows, use [`COMPRESSION_LZ4`](/documentation/Compression/COMPRESSION_LZ4), [`COMPRESSION_LZMA`](/documentation/Compression/COMPRESSION_LZMA), or [`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB) instead. Apple does publish an open-source LZFSE reference implementation, but it isn’t as widely available as [`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB) or [`COMPRESSION_LZMA`](/documentation/Compression/COMPRESSION_LZMA).

LZFSE is supported by both the buffer API — [`compression_encode_buffer(_:_:_:_:_:_:)`](/documentation/Compression/compression_encode_buffer(_:_:_:_:_:_:)) and [`compression_decode_buffer(_:_:_:_:_:_:)`](/documentation/Compression/compression_decode_buffer(_:_:_:_:_:_:)) — and the streaming API via [`compression_stream_init(_:_:_:)`](/documentation/Compression/compression_stream_init(_:_:_:)), so you can use it for in-memory payloads or for processing data incrementally as it arrives.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)