<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSData/base64EncodedString(options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSData(im)base64EncodedStringWithOptions:"
  },
  "title" : "base64EncodedString(options:)"
}
-->

# base64EncodedString(options:)

Creates a Base64 encoded string from the string using the given options.

```
func base64EncodedString(options: NSData.Base64EncodingOptions = []) -> String
```

## Parameters

`options`

A mask that specifies options for Base-64 encoding the data. Possible values are given in [`NSData.Base64EncodingOptions`](/documentation/Foundation/NSData/Base64EncodingOptions).

## Return Value

A Base64 encoded string.

## Discussion

By default, no line endings are inserted.

If you specify one of the line length options ([`lineLength64Characters`](/documentation/Foundation/NSData/Base64EncodingOptions/lineLength64Characters) or [`lineLength76Characters`](/documentation/Foundation/NSData/Base64EncodingOptions/lineLength76Characters)) but don’t specify the kind of line ending to insert, the default line ending is Carriage Return + Line Feed.

---

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)