JSON to Swift Codable Converter

Paste a JSON response and get Swift Codable models ready to use: nested structs, arrays, optionals, CodingKeys or keyDecodingStrategy, ISO 8601 dates and the code to decode it.

Input JSON
Swift code

    🔒 Everything is processed in your browser. Your JSON is never sent to any server.

    Options

    • Type: struct (recommended) or final class.
    • Keys: explicit CodingKeys, or .convertFromSnakeCase when every key is snake_case.
    • Protocol: Codable or just Decodable if you only read data.
    • Optionals: a field becomes optional if it is null or missing in some element of an array; you can also make everything optional.
    • Extras: Sendable, Hashable and Identifiable when there is an id.

    How to decode the result

    let decoder = JSONDecoder()
    decoder.dateDecodingStrategy = .iso8601
    let response = try decoder.decode(Response.self, from: data)

    Paste several elements of an array rather than just one: the more samples the tool sees, the better it infers which fields are optional.

    Frequently asked questions

    What happens with null values?

    A field that is always null in your sample does not reveal its type, so it is marked with a TODO comment for you to adjust.

    Why does a number like 3.0 become Int?

    JSON does not distinguish integers from decimals. If a field can have decimals, change it to Double.

    Is my JSON sent anywhere?

    No. The conversion runs entirely in your browser, so you can paste real API responses.

    ¿Prefieres español? Esta herramienta en español.