Swiftpack.co -  webfrogs/Transformers as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A framework to transform data like JSON elegantly using the power of Swift programming language.
.package(url: "https://github.com/webfrogs/Transformers.git", from: "1.0.1")

Carthage compatible Platform Swift Package Manager compatible

Transformers is a framework to transform things elegantly using the power of Swift programming language.

Note: Support Swift version: 4.1 or newer


  • Cast JSON data with type.
  • Cast a swift dictionary to swift model which confirms Codable protocol.
  • Cast a swift array whose item type is dictionary to swift model array whose items confirm Codable protocol.



Download the project, and drag the Core folder to your project.


Add this to Cartfile

github "webfrogs/Transformers" ~> 1.0

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/webfrogs/Transformers.git", .upToNextMinor(from: "1.0.0")),


The most common scene in iOS programming is handle JSON data.

Handle JSON

let jsonString = """
{"key1": "value2"}
let value1: String? = jsonString.data(using: String.Encoding.utf8)
    .flatMap({$0.value(key: "key1")})
print(value1 ?? "")


If you also use RxSwift in your project. Transformers can be easily integrated with RxSwift, and there is no need to transform JSON data fetched from http server to a model manually. All you have to do is define a model which confirms Codable protocol and use Transformers with the map function provided by RxSwift.

Here is a demo code:

struct GithubAPIResult: Codable {
    let userUrl: String
    let issueUrl: String

    enum CodingKeys: String, CodingKey {
        case userUrl = "user_url"
        case issueUrl = "issues_url"

let request = URLRequest(url: URL(string: "https://api.github.com")!)
let apiResult: Observable<GithubAPIResult> = URLSession.shared
    .rx.data(request: request)
apiResult.subscribe(onNext: { (result) in
}).disposed(by: kDisposeBag)


Stars: 42
Last commit: 3 years ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics