<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSMutableData/decompress(using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMutableData(im)decompressUsingAlgorithm:error:"
  },
  "title" : "decompress(using:)"
}
-->

# decompress(using:)

Decompresses the data object’s bytes.

```
func decompress(using algorithm: NSData.CompressionAlgorithm) throws
```

## Parameters

`algorithm`

The algorithm to use for decompressing the data. For a list of available algorithms, see [`NSData.CompressionAlgorithm`](/documentation/Foundation/NSData/CompressionAlgorithm).

## Discussion

Use this method to inflate in-memory data when you need uncompressed bytes. Specify the same algorithm used to compress the data to successfully decompress it.

The following example shows how to inflate an instance of [`NSMutableData`](/documentation/Foundation/NSMutableData) compressed with the [`NSData.CompressionAlgorithm.zlib`](/documentation/Foundation/NSData/CompressionAlgorithm/zlib) algorithm:

```swift
do {
    data.decompress(using: .zlib)
} catch {
    print ("Decompression error: \(error)")
}
```

---

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)