You’ve been over-engineering your Swift models. “Should this model be Decodable or Codable? Am I doing this wrong?” — Here's how to pick the right one.
Swift doesn’t provide a single “JSON protocol.” It gives you three, each with a specific responsibility
Most networking code only needs Decodable
When your app fetches data and displays it, data flows one way — from the server into your models. The Decodable conformance is a signal to anyone reading this code: this model is read-only by design. You don’t need Codable here, just in case.
struct Article : Decodable { let id : Int let title : String let publishedAt : Date let author : Author }
Enter fullscreen mode
Exit fullscreen mode
Use Codable when data moves in both directions
Two situations make Codable the right call:
You’re sending data back to a server
A request body going out as JSON, a form payload, a PUT with updated fields — anything where your Swift type needs to become JSON.
struct UpdateProfileRequest : Encodable { let displayName :…