JSON to Swift Codable
Infer Swift Codable structs and CodingKeys from a sample JSON object.
Create Codable structs for Swift clients
Codable removes much of the manual parsing from Swift networking, but the model declarations still have to mirror each JSON field. This tool inspects a sample object and creates Codable structs for the root and nested records. Integer values become Int, decimals become Double, booleans become Bool, text becomes String, and arrays receive bracketed element types inferred from their examples.
The default payload becomes struct User with userId, name, and active properties. Its CodingKeys enum maps userId back to user_id, while already matching names need no extra case. Objects nested under profile or arrays such as orders produce additional Swift structs, making the result useful for URLSession response models and fixture decoding.
Sampling limits and CodingKeys
Generated declarations reflect only what the sample demonstrates. Null uses a broad optional wrapper, empty arrays cannot reveal an element type, and fields missing from this example are not discovered. Processing is confined to your browser. Before shipping, decide which values are optional, whether dates need Date decoding, and whether integer identifiers should remain Int or become String.
Frequently Asked Questions
When is a CodingKeys enum included?
It is included when a Swift camel-case property name differs from its original JSON key.
Does the generator recognize dates?
No. JSON dates are strings syntactically, so convert selected properties to Date and configure a decoder manually.
How are arrays of objects modeled?
They become arrays of a generated child Codable struct inferred from the first item.
Browse the full set of free, private, in-browser tools.