Code Generators · Runs in your browser
JSON to Swift Codable Struct Generator
Paste a JSON sample and get ready-to-use Swift Codable structs, with nested types, arrays and optional fields worked out for you. Ideal for decoding JSON with JSONDecoder in iOS and macOS apps.
JSON
Drop a file to load it
Swift
How to use it
- Paste a representative JSON sample, such as an API response.
- Set the root type name and pick a style: Codable structs.
- Copy the Swift code or download it as a file.
CodingKeys
Properties use Swift naming, and a CodingKeys enum maps them to the original keys when they differ.
Mixed values
Fields with mixed types use a small JSONValue enum that is included in the output only when needed.
Integers vs. decimals
Number types come from how the number is written in your sample: 3 is an integer, 3.0 and 3.5 are decimals, and long IDs use a 64-bit type.
More code generators tools
All free, all private, all running locally in your browser.