<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSString/pathExtension",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(py)pathExtension"
  },
  "title" : "pathExtension"
}
-->

# pathExtension

The path extension, if any, of the string as interpreted as a path.

```
var pathExtension: String { get }
```

## Discussion

The path extension is the portion of the last path component which follows the final period, if there is one. The extension divider is not included. The following table illustrates the effect of [`pathExtension`](/documentation/Foundation/NSString/pathExtension) on a variety of different paths:

|Receiver’s String Value|String Returned     |
|-----------------------|--------------------|
|“`/tmp/scratch.tiff`”  |“`tiff`”            |
|“`.scratch.tiff`”      |“`tiff`”            |
|“`/tmp/scratch`”       |“” (an empty string)|
|“`/tmp/`”              |“” (an empty string)|
|“`/tmp/scratch..tiff`” |“`tiff`”            |

Note that this method only works with file paths (not, for example, string representations of URLs).

---

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)