---
title: ConvertibleToBytes
framework: Swift
role: symbol
role_heading: Protocol
platforms: [iOS 8.0+, iPadOS 8.0+, Mac Catalyst 13.0+, macOS 10.10+, tvOS 9.0+, visionOS 1.0+, watchOS 2.0+]
path: swift/convertibletobytes
---

# ConvertibleToBytes

A protocol for types whose memory can safely be read as individual raw bytes.

## Declaration

```swift
protocol ConvertibleToBytes
```

## Overview

Overview A type can conform to ConvertibleToBytes if its memory representation includes no padding. The sum of the size of its stored properties must be equal to its stride. A type that conforms to ConvertibleToBytes must have: one or more stored properties, all of its stored properties have a type which conforms to ConvertibleToBytes, its stored properties are stored contiguously in memory, with no padding, none of its values disregards a subset of its bytes, making most enums ineligible.

## Relationships

### Conforming Types

- [Bool](swift/bool.md)
- [ClosedRange](swift/closedrange.md)
- [CollectionOfOne](swift/collectionofone.md)
- [Double](swift/double.md)
- [Duration](swift/duration.md)
- [Float](swift/float.md)
- [Float16](swift/float16.md)
- [InlineArray](swift/inlinearray.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)
- [ObjectIdentifier](swift/objectidentifier.md)
- [OpaquePointer](swift/opaquepointer.md)
- [PartialRangeFrom](swift/partialrangefrom.md)
- [PartialRangeFrom.Iterator](swift/partialrangefrom/iterator.md)
- [PartialRangeThrough](swift/partialrangethrough.md)
- [PartialRangeUpTo](swift/partialrangeupto.md)
- [Range](swift/range.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)
- [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)

## See Also

### Safe Access to Raw Bytes

- [FullyInhabited](swift/fullyinhabited.md)
- [ConvertibleFromBytes](swift/convertiblefrombytes.md)
- [ByteOrder](swift/byteorder.md)
- [bitCast(_:to:)](swift/bitcast(_:to:).md)
