Generate Swift Codable structs from a typical REST API JSON response. Paste your API JSON output and get typed Swift Codable structs for Xcode projects.
// Generated by DevBento — json-to-typescript
interface RootAddress {
street: string;
city: string;
zip: string;
}
interface RootPostsItem {
title: string;
likes?: number;
}
interface Root {
id: number;
name: string;
email: string;
isActive: boolean;
roles: string[];
address: RootAddress;
posts: RootPostsItem[];
}This example generates Swift Codable structs from a typical REST API response. The pre-filled JSON represents a user object with nested address, array of roles, and array of post objects. Switch to Swift mode to see the generated structs.
The tool produces:
Root struct conforming to CodableRootAddress struct for the nested address objectRootPostsItem struct for array itemsCodingKeys enum when property names differ from JSON keysT?) for optional fieldsString, Int, Double, Bool, [String]Swift Codable structs are the standard way to decode JSON in iOS and macOS apps. The generated code works directly with JSONDecoder().decode(T.self, from: data). Use optional types for fields that may not always be present in the response.
Nothing you paste leaves this tab. Every tool runs entirely in your browser — no upload, no server, no account.