---
title: length
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/nsstring/length
---

# length

The number of UTF-16 code units in the receiver.

## Declaration

```swift
var length: Int { get }
```

## Discussion

Discussion This number includes the individual characters of composed character sequences, so you cannot use this property to determine if a string will be visible when printed or how long it will appear.

## See Also

### Related Documentation

- [size(withAttributes:)](foundation/nsstring/size(withattributes:).md)

### Getting a String’s Length

- [lengthOfBytes(using:)](foundation/nsstring/lengthofbytes(using:).md)
- [maximumLengthOfBytes(using:)](foundation/nsstring/maximumlengthofbytes(using:).md)
