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

# COMPRESSION_ZLIB

The zlib compression algorithm, which is recommended for cross-platform compression.

```
var COMPRESSION_ZLIB: compression_algorithm { get }
```

## Discussion

The Compression library implements the zlib encoder at level 5 only.  This compression level provides a good balance between compression speed and compression ratio.  The zlib decoder supports decoding data compressed with any compression level.

The encoded format is the raw `DEFLATE` format as described in [IETF RFC 1951](https://www.ietf.org/rfc/rfc1951.txt), the following obtains the equivalent configuration of the encoder:

```c
deflateInit2(zstream,5,Z_DEFLATED,-15,8,Z_DEFAULT_STRATEGY)
```

---

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)