# All channels
#315: Codable Basics 📠August 17, 2017 at 7:09pm (Edited 3 years ago)
Swift 4 has brought with it a ton of great improvements. Today we'll cover one of them, it's the new Codable protocol!
Codable ships with Swift 4 as part of the Swift standard library and allows us to conform our own types to it to get encoding and decoding functionality "for free". Encoding and decoding types has never been easier.
Let's dive in!
Before we begin lets back up a second and look at what we're trying to accomplish when it comes to encoding and decoding.
Essentially we want to take an instance of an object or struct and convert (or "encode") it into some other, (usually "machine-readable") format. Then, later, we want to be able to convert (or "decode") the information in that format back into our object or struct.
These days the most common format for encoding/decoding is JSON. It's supported just about everywhere and has the advantage of being both human and machine readable.
For this reason, we'll be discussing JSON in this Bite. It's important to note though, that Codable isn't specific to just JSON. It's built to support encoding and decoding into just about any format we can think of.
In the past, we might have used something like the JSONSerialization class in Foundation to do encode our types into JSON.
This works great, but the encoding input and decoding output was either a Dictionary<String: Any>, or an Array of them. Then we'd need to manually convert to/from our "real" types.
With Codable, we can do much better!