Swift Codable Generator

JSON Formatter & Validator for Swift

Validate JSON syntax, format with custom indentation, and convert API payloads directly into production-grade Swift Codable structs with automatic CodingKeys.

JSON Input
Generated Swift Codable
public struct UserResponse: Codable, Identifiable {
    public let id: String
    public let username: String
    public let displayName: String
    public let isProMember: Bool
    public let reputationScore: Double
    public let createdAt: String
    public let profile: Profile
    public let tags: [String]
    public let recentProjects: [RecentProject]

    enum CodingKeys: String, CodingKey {
        case id
        case username
        case displayName = "display_name"
        case isProMember = "is_pro_member"
        case reputationScore = "reputation_score"
        case createdAt = "created_at"
        case profile
        case tags
        case recentProjects = "recent_projects"
    }
}

public struct RecentProject: Codable {
    public let projectId: Int
    public let title: String
    public let version: String
    public let stars: Int

    enum CodingKeys: String, CodingKey {
        case projectId = "project_id"
        case title
        case version
        case stars
    }
}

public struct Profile: Codable {
    public let bio: String
    public let avatarUrl: String
    public let followersCount: Int

    enum CodingKeys: String, CodingKey {
        case bio
        case avatarUrl = "avatar_url"
        case followersCount = "followers_count"
    }
}

Why use Swift Codable Structs with CodingKeys?

Idiomatic Swift Naming

REST APIs frequently return snake_case keys like user_profile_id. This tool maps them cleanly to Swift camelCase via an automated CodingKeys enum.

Nested Schema Detection

Child objects and arrays automatically generate individual typed structs rather than fallback dictionary types, guaranteeing compile-time type safety in SwiftUI.

Identifiable Conformance

Objects containing an id property automatically conform to Identifiable, enabling direct usage in SwiftUI List and ForEach views.

Thorous icon

Build full iPhone apps without touching Xcode

Enjoying this free JSON to Swift Converter? Thorous turns your natural language prompts into compiled native SwiftUI apps, with real-time iOS simulator streaming and visual on-screen editing.

Native Mac app · macOS 14 Sonoma or later · Apple silicon & Intel