---
title: CustomStringConvertible
framework: swift
role: symbol
role_heading: Protocol
path: swift/customstringconvertible
---

# CustomStringConvertible

A type with a customized textual representation.

## Declaration

```swift
protocol CustomStringConvertible
```

## Overview

Overview Types that conform to the CustomStringConvertible protocol can provide their own representation to be used when converting an instance to a string. The String(describing:) initializer is the preferred way to convert an instance of any type to a string. If the passed instance conforms to CustomStringConvertible, the String(describing:) initializer and the print(_:) function use the instance’s custom description property. Accessing a type’s description property directly or using CustomStringConvertible as a generic constraint is discouraged. Conforming to the CustomStringConvertible Protocol Add CustomStringConvertible conformance to your custom types by defining a description property. For example, this custom Point struct uses the default representation supplied by the standard library: struct Point {     let x: Int, y: Int }

let p = Point(x: 21, y: 30) print(p) // Prints "Point(x: 21, y: 30)" After implementing the description property and declaring CustomStringConvertible conformance, the Point type provides its own custom representation. extension Point: CustomStringConvertible {     var description: String {         return "(\(x), \(y))"     } }

print(p) // Prints "(21, 30)"

## Topics

### Instance Properties

- [description](swift/customstringconvertible/description.md)

## Relationships

### Inherited By

- [BinaryInteger](swift/binaryinteger.md)
- [CodingKey](swift/codingkey.md)
- [FixedWidthInteger](swift/fixedwidthinteger.md)
- [LosslessStringConvertible](swift/losslessstringconvertible.md)
- [SIMD](swift/simd.md)
- [SignedInteger](swift/signedinteger.md)
- [StringProtocol](swift/stringprotocol.md)
- [UnsignedInteger](swift/unsignedinteger.md)

### Conforming Types

- [AnyHashable](swift/anyhashable.md)
- [Array](swift/array.md)
- [ArraySlice](swift/arrayslice.md)
- [AtomicLoadOrdering](synchronization/atomicloadordering.md)
- [AtomicStoreOrdering](synchronization/atomicstoreordering.md)
- [AtomicUpdateOrdering](synchronization/atomicupdateordering.md)
- [Bool](swift/bool.md)
- [Character](swift/character.md)
- [ClosedRange](swift/closedrange.md)
- [ContiguousArray](swift/contiguousarray.md)
- [DefaultStringInterpolation](swift/defaultstringinterpolation.md)
- [Dictionary](swift/dictionary.md)
- [Dictionary.Keys](swift/dictionary/keys-swift.struct.md)
- [Dictionary.Values](swift/dictionary/values-swift.struct.md)
- [DiscontiguousSlice](swift/discontiguousslice.md)
- [DiscontiguousSlice.Index](swift/discontiguousslice/index.md)
- [Double](swift/double.md)
- [Duration](swift/duration.md)
- [Float](swift/float.md)
- [Float16](swift/float16.md)
- [Float80](swift/float80.md)
- [Int](swift/int.md)
- [Int128](swift/int128.md)
- [Int16](swift/int16.md)
- [Int32](swift/int32.md)
- [Int64](swift/int64.md)
- [Int8](swift/int8.md)
- [KeyValuePairs](swift/keyvaluepairs.md)
- [Mirror](swift/mirror.md)
- [Range](swift/range.md)
- [RangeSet](swift/rangeset.md)
- [RangeSet.Ranges](swift/rangeset/ranges-swift.struct.md)
- [RemoteCallTarget](distributed/remotecalltarget.md)
- [SIMD16](swift/simd16.md)
- [SIMD2](swift/simd2.md)
- [SIMD3](swift/simd3.md)
- [SIMD32](swift/simd32.md)
- [SIMD4](swift/simd4.md)
- [SIMD64](swift/simd64.md)
- [SIMD8](swift/simd8.md)
- [SIMDMask](swift/simdmask.md)
- [Set](swift/set.md)
- [StaticString](swift/staticstring.md)
- [String](swift/string.md)
- [String.Encoding](swift/string/encoding.md)
- [String.UTF16View](swift/string/utf16view.md)
- [String.UTF8View](swift/string/utf8view.md)
- [String.UnicodeScalarView](swift/string/unicodescalarview.md)
- [Substring](swift/substring.md)
- [TaskLocal](swift/tasklocal.md)
- [TaskPriority](swift/taskpriority.md)
- [UInt](swift/uint.md)
- [UInt128](swift/uint128.md)
- [UInt16](swift/uint16.md)
- [UInt32](swift/uint32.md)
- [UInt64](swift/uint64.md)
- [UInt8](swift/uint8.md)
- [Unicode.Scalar](swift/unicode/scalar.md)
- [Unicode.UTF8.ValidationError](swift/unicode/utf8/validationerror.md)
- [Unicode.UTF8.ValidationError.Kind](swift/unicode/utf8/validationerror/kind-swift.struct.md)
- [UnownedJob](swift/unownedjob.md)
- [WordPair](synchronization/wordpair.md)

## See Also

### String Representation

- [LosslessStringConvertible](swift/losslessstringconvertible.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
