Skip to content
ZeroServer.tools

JSON to Swift Struct

Generate a Swift struct with Codable conformance from a JSON sample.

import Foundation

struct Root: Codable {
    let id: Int
    let name: String
    let email: String
    let score: Double
    let active: Bool
    let tags: [String]
    let address: Address
}

struct Address: Codable {
    let street: String
    let city: String
}

How JSON to Swift struct generation works

JSON types map to Swift: strings → String, integers → Int, decimals → Double, booleans → Bool, arrays → [T], and null values → optional types. All structs conform to Codable (bothEncodable and Decodable). CodingKeysare generated automatically when JSON keys don't match Swift camelCase naming.

For Kotlin equivalents, try JSON to Kotlin. For TypeScript, see JSON to TypeScript.

Private & free — this tool runs entirely in your browser.

Recommended: IndieKit Ship your Next.js startup in days.affiliate

Related Converters tools