---
title: CustomDebugStringConvertible
framework: swift
role: symbol
role_heading: Protocol
path: swift/customdebugstringconvertible
---

# CustomDebugStringConvertible

A type with a customized textual representation suitable for debugging purposes.

## Declaration

```swift
protocol CustomDebugStringConvertible
```

## Overview

Overview Swift provides a default debugging textual representation for any type. That default representation is used by the String(reflecting:) initializer and the debugPrint(_:) function for types that don’t provide their own. To customize that representation, make your type conform to the CustomDebugStringConvertible protocol. Because the String(reflecting:) initializer works for instances of any type, returning an instance’s debugDescription if the value passed conforms to CustomDebugStringConvertible, accessing a type’s debugDescription property directly or using CustomDebugStringConvertible as a generic constraint is discouraged. note: Calling the dump(_:_:_:_:) function and printing in the debugger uses both String(reflecting:) and Mirror(reflecting:) to collect information about an instance. If you implement CustomDebugStringConvertible conformance for your custom type, you may want to consider providing a custom mirror by implementing CustomReflectable conformance, as well. Conforming to the CustomDebugStringConvertible Protocol Add CustomDebugStringConvertible conformance to your custom types by defining a debugDescription 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(String(reflecting: p)) // Prints "Point(x: 21, y: 30)" After adding CustomDebugStringConvertible conformance by implementing the debugDescription property, Point provides its own custom debugging representation. extension Point: CustomDebugStringConvertible {     var debugDescription: String {         return "(\(x), \(y))"     } }

print(String(reflecting: p)) // Prints "(21, 30)"

## Topics

### Instance Properties

- [debugDescription](swift/customdebugstringconvertible/debugdescription.md)

## Relationships

### Inherited By

- [CodingKey](swift/codingkey.md)

### Conforming Types

- [AnyHashable](swift/anyhashable.md)
- [AnyKeyPath](swift/anykeypath.md)
- [Array](swift/array.md)
- [ArraySlice](swift/arrayslice.md)
- [AutoreleasingUnsafeMutablePointer](swift/autoreleasingunsafemutablepointer.md)
- [CVaListPointer](swift/cvalistpointer.md)
- [Character](swift/character.md)
- [ClosedRange](swift/closedrange.md)
- [CollectionOfOne](swift/collectionofone.md)
- [ContiguousArray](swift/contiguousarray.md)
- [DecodingError](swift/decodingerror.md)
- [Dictionary](swift/dictionary.md)
- [Dictionary.Keys](swift/dictionary/keys-swift.struct.md)
- [Dictionary.Values](swift/dictionary/values-swift.struct.md)
- [Double](swift/double.md)
- [EncodingError](swift/encodingerror.md)
- [Float](swift/float.md)
- [Float16](swift/float16.md)
- [Float80](swift/float80.md)
- [KeyPath](swift/keypath.md)
- [KeyValuePairs](swift/keyvaluepairs.md)
- [ObjectIdentifier](swift/objectidentifier.md)
- [OpaquePointer](swift/opaquepointer.md)
- [Optional](swift/optional.md)
- [PartialKeyPath](swift/partialkeypath.md)
- [Range](swift/range.md)
- [ReferenceWritableKeyPath](swift/referencewritablekeypath.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)
- [Set](swift/set.md)
- [StaticBigInt](swift/staticbigint.md)
- [StaticString](swift/staticstring.md)
- [String](swift/string.md)
- [String.Index](swift/string/index.md)
- [String.UTF16View](swift/string/utf16view.md)
- [String.UTF8View](swift/string/utf8view.md)
- [String.UnicodeScalarView](swift/string/unicodescalarview.md)
- [Substring](swift/substring.md)
- [Unicode.Scalar](swift/unicode/scalar.md)
- [UnsafeBufferPointer](swift/unsafebufferpointer.md)
- [UnsafeMutableBufferPointer](swift/unsafemutablebufferpointer.md)
- [UnsafeMutablePointer](swift/unsafemutablepointer.md)
- [UnsafeMutableRawBufferPointer](swift/unsafemutablerawbufferpointer.md)
- [UnsafeMutableRawPointer](swift/unsafemutablerawpointer.md)
- [UnsafePointer](swift/unsafepointer.md)
- [UnsafeRawBufferPointer](swift/unsaferawbufferpointer.md)
- [UnsafeRawPointer](swift/unsaferawpointer.md)
- [WordPair](synchronization/wordpair.md)
- [WritableKeyPath](swift/writablekeypath.md)

## See Also

### String Representation

- [CustomStringConvertible](swift/customstringconvertible.md)
- [LosslessStringConvertible](swift/losslessstringconvertible.md)
