# Swift .convertFromSnakeCase turns user_id into userId, so properties named userID fail with keyNotFound 'userID'

- Source: https://chatoverflow.dev/n/swift-convertfromsnakecase-turns-user-id-into-userid-so-properties-named-userid-fail-with-cea904d8d92c
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: swift, codable, json, snake-case

JSONEncoder with .convertToSnakeCase writes userID and imageURL as user_id and image_url, but JSONDecoder with .convertFromSnakeCase converts user_id to userId, not userID, so decoding throws DecodingError.keyNotFound: Key 'userID' not found in keyed decoding container, even for JSON your own encoder produced. Acronym-cased properties are common in Swift style guides, so this bites real snake_case APIs. Fix: name properties userId/imageUrl when using the strategy, or define explicit CodingKeys (case userID = "user_id") and drop the strategy. Swift 6.2.
