<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/encoding-decoding-and-serialization",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Encoding, Decoding, and Serialization"
}
-->

# Encoding, Decoding, and Serialization

Serialize and deserialize instances of your types with implicit or customized encoding.

## Topics

### Custom Encoding and Decoding

  <doc://com.apple.documentation/documentation/Foundation/encoding-and-decoding-custom-types>

[`Codable`](/documentation/Swift/Codable)

A type that can convert itself into and out of an external representation.

[`Encodable`](/documentation/Swift/Encodable)

A type that can encode itself to an external representation.

[`Decodable`](/documentation/Swift/Decodable)

A type that can decode itself from an external representation.

[`CodingKey`](/documentation/Swift/CodingKey)

A type that can be used as a key for encoding and decoding.

[`CodingKeyRepresentable`](/documentation/Swift/CodingKeyRepresentable)

A type that can be converted to and from a coding key.

[`CodingUserInfoKey`](/documentation/Swift/CodingUserInfoKey)

A user-defined key for providing context during encoding and decoding.

### Encoders and Decoders

[`Encoder`](/documentation/Swift/Encoder)

A type that can encode values into a native format for external
representation.

[`Decoder`](/documentation/Swift/Decoder)

A type that can decode values from a native format into in-memory
representations.

[`EncodingError`](/documentation/Swift/EncodingError)

An error that occurs during the encoding of a value.

[`DecodingError`](/documentation/Swift/DecodingError)

An error that occurs during the decoding of a value.

### Encoding Containers

[`SingleValueEncodingContainer`](/documentation/Swift/SingleValueEncodingContainer)

A container that can support the storage and direct encoding of a single
non-keyed value.

[`KeyedEncodingContainer`](/documentation/Swift/KeyedEncodingContainer)

A concrete container that provides a view into an encoder’s storage, making
the encoded properties of an encodable type accessible by keys.

[`KeyedEncodingContainerProtocol`](/documentation/Swift/KeyedEncodingContainerProtocol)

A type that provides a view into an encoder’s storage and is used to hold
the encoded properties of an encodable type in a keyed manner.

[`UnkeyedEncodingContainer`](/documentation/Swift/UnkeyedEncodingContainer)

A type that provides a view into an encoder’s storage and is used to hold
the encoded properties of an encodable type sequentially, without keys.

### Decoding Containers

[`KeyedDecodingContainer`](/documentation/Swift/KeyedDecodingContainer)

A concrete container that provides a view into a decoder’s storage, making
the encoded properties of a decodable type accessible by keys.

[`SingleValueDecodingContainer`](/documentation/Swift/SingleValueDecodingContainer)

A container that can support the storage and direct decoding of a single
nonkeyed value.

[`KeyedDecodingContainerProtocol`](/documentation/Swift/KeyedDecodingContainerProtocol)

A type that provides a view into a decoder’s storage and is used to hold
the encoded properties of a decodable type in a keyed manner.

[`UnkeyedDecodingContainer`](/documentation/Swift/UnkeyedDecodingContainer)

A type that provides a view into a decoder’s storage and is used to hold
the encoded properties of a decodable type sequentially, without keys.



---

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)