JSON to Swift Codable
Generate Swift Codable structs from JSON. Use with JSONDecoder at the API boundary; the compiler enforces shape at compile time. ISO 8601 dates become Date (configure your decoder's dateDecodingStrategy to .iso8601).
How to use the JSON to Swift Codable
Paste JSON. Output is ready to drop into your iOS / macOS app. For snake_case JSON keys, set JSONDecoder().keyDecodingStrategy = .convertFromSnakeCase and use camelCase field names in Swift.
Generating Swift Codable structs from JSON
Swift’s Codable makes JSON decoding clean and type-safe, but only once you have written structs that exactly match the payload. Doing that by hand from a sample response is tedious, and a single mismatched property quietly turns into a decoding error at runtime rather than a compile-time complaint.
This generates Swift Codable structs from a JSON sample, nesting a struct per nested object, ready to decode with JSONDecoder so the compiler enforces the shape. ISO 8601 date strings map to Date — set your decoder’s dateDecodingStrategy to .iso8601 — and for snake_case keys set keyDecodingStrategy to .convertFromSnakeCase and keep camelCase field names. The output drops straight into an iOS or macOS app.
Common use cases
- Decode an API — generate Codable structs for a sample response.
- iOS and macOS — drop the structs into an app’s networking layer.
- Typed dates — map ISO 8601 strings to
Datewith.iso8601. - snake_case keys — use
.convertFromSnakeCasewith camelCase fields. - Nested structs — produce a struct for each nested object.