<!--
{
  "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/NSData/decompressed(using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSData(im)decompressedDataUsingAlgorithm:error:"
  },
  "title" : "decompressed(using:)"
}
-->

# decompressed(using:)

Returns a new data object by decompressing data object’s bytes.

```
func decompressed(using algorithm: NSData.CompressionAlgorithm) throws -> Self
```

## Parameters

`algorithm`

An algorithm used to decompress the data. For a list of available algorithms, see [`NSData.CompressionAlgorithm`](/documentation/Foundation/NSData/CompressionAlgorithm).

## Return Value

An [`NSData`](/documentation/Foundation/NSData) instance that contains the decompressed buffer data.

## 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 create a new [`NSData`](/documentation/Foundation/NSData) instance from data compressed with the [`NSData.CompressionAlgorithm.zlib`](/documentation/Foundation/NSData/CompressionAlgorithm/zlib) algorithm:

```swift
do {
    let uncompressedData = try compressedData.decompressed(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)