JSON to Swift
Paste a JSON sample, such as an API response, and Bracely writes Swift Codable structs for it. Each object becomes a struct that conforms to Codable, with CodingKeys when a key isn't a valid Swift name.
How to use it
- Paste a JSON sample.
- Set the root type name, for example Order.
- Copy the Swift code into your project.
What it does
- Codable structs you can decode with JSONDecoder
- Optionals for fields that can be missing
- Arrays typed as [T]
- Nested objects become their own named types
- 12 other languages from the same sample, including TypeScript
Questions
- How does it pick Swift types?
- From the values in your sample: whole numbers, decimals, text, true/false, arrays and nested objects. When array items disagree, the field is made optional or widened.
- Can I generate other languages?
- Yes. Change Language to TypeScript, Go, Python, Java, C#, Rust, Kotlin, Swift, Dart, PHP, Zod, GraphQL or Protobuf.
- Is my data uploaded?
- No. Bracely runs entirely in your browser, so nothing you paste or open leaves your device.
More JSON tools
Bracely has more than 60 JSON tools in one page. Related ones:
Runs entirely in your browser. Nothing you paste is uploaded. Privacy policy