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

# compression_algorithm

A structure for values that represent compression algorithms.

```
struct compression_algorithm
```

## Overview

Choose an algorithm according to the following guidelines:

- If speed and compression ratio are important, use [`COMPRESSION_LZMESH`](/documentation/Compression/COMPRESSION_LZMESH).
- If you require interoperability with non-Apple devices, use [`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB).
- If speed is critical, and you’re willing to sacrifice compression ratio to achieve it, use [`COMPRESSION_LZ4`](/documentation/Compression/COMPRESSION_LZ4).
- If compression ratio is critical, and you can sacrifice speed to achieve it, use [`COMPRESSION_LZRAVEN`](/documentation/Compression/COMPRESSION_LZRAVEN). Note that [`COMPRESSION_LZRAVEN`](/documentation/Compression/COMPRESSION_LZRAVEN) is an order of magnitude slower for both compression and decompression than other choices.

[`COMPRESSION_LZMESH`](/documentation/Compression/COMPRESSION_LZMESH) is faster than [`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB) and generally achieves a better compression ratio. However, it’s slower than [`COMPRESSION_LZ4`](/documentation/Compression/COMPRESSION_LZ4) and doesn’t compress as well as [`COMPRESSION_LZRAVEN`](/documentation/Compression/COMPRESSION_LZRAVEN).

[`COMPRESSION_LZBITMAP`](/documentation/Compression/COMPRESSION_LZBITMAP) provides a compression-ratio that’s between [`COMPRESSION_LZ4`](/documentation/Compression/COMPRESSION_LZ4) and [`COMPRESSION_LZMESH`](/documentation/Compression/COMPRESSION_LZMESH). When compression ratio and performance are equally important, use [`COMPRESSION_LZMESH`](/documentation/Compression/COMPRESSION_LZMESH) to favor compression ratio and [`COMPRESSION_LZBITMAP`](/documentation/Compression/COMPRESSION_LZBITMAP) to favor performance.

## Topics

### Algorithm Constants

[`COMPRESSION_LZFSE`](/documentation/Compression/COMPRESSION_LZFSE)

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

[`COMPRESSION_LZ4`](/documentation/Compression/COMPRESSION_LZ4)

The LZ4 compression algorithm for fast compression.

[`COMPRESSION_LZ4_RAW`](/documentation/Compression/COMPRESSION_LZ4_RAW)

The LZ4 compression algorithm, without frame headers.

[`COMPRESSION_LZMA`](/documentation/Compression/COMPRESSION_LZMA)

The LZMA compression algorithm, which is recommended for high-compression ratio.

[`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB)

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

[`COMPRESSION_BROTLI`](/documentation/Compression/COMPRESSION_BROTLI)

The Brotli compression algorithm, which is recommended for text compression.

[`COMPRESSION_LZBITMAP`](/documentation/Compression/COMPRESSION_LZBITMAP)

The LZBITMAP compression algorithm, which is designed to exploit the vector instruction set of current CPUs.

[`COMPRESSION_LZMESH`](/documentation/Compression/COMPRESSION_LZMESH)

The LZMESH compression algorithm, which is recommended for fast, general-purpose compression on Apple platforms.

[`COMPRESSION_LZRAVEN`](/documentation/Compression/COMPRESSION_LZRAVEN)

The LZRAVEN compression algorithm, which is recommended for high-compression ratio with fast decoding on Apple platforms.

### Initializers

[`init(_:)`](/documentation/Compression/compression_algorithm/init(_:))

Creates a new constant from the given raw value.

[`init(rawValue:)`](/documentation/Compression/compression_algorithm/init(rawValue:))

Creates a new constant from the given raw value.

### Instance Properties

[`rawValue`](/documentation/Compression/compression_algorithm/rawValue)

The raw value of the constant.



---

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)