Generate a Swift struct from JSON

Paste a JSON object to automatically generate the matching Swift structs conforming to Codable, with recursive type inference (String, Int, Double, Bool, arrays, nested structs). Nothing is sent to a server.

Example:

How it works

The tool recursively walks the JSON object and maps each property to a suitable Swift type: String, Int, Double, Bool, an array [Type], or a new nested struct conforming to Codable for each object encountered, which then allows native JSON decoding with JSONDecoder.

Why does a "null" value become "String?"?

A null value gives no hint about the real type the API expects. The tool assumes the most common case by default (String?, an optional); it's recommended to adjust the exact type manually (for example Int?) once you know the real format of the data.

Why use "let" rather than "var" for properties?

The structs generated by this tool are designed for read-only JSON decoding (via Codable): using let encourages immutability, a recommended practice in Swift. Replace it with var if you need to modify values after decoding.

Privacy: the JSON → Swift conversion runs entirely in your browser, without sending your data to a server.