Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

469 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

👻 Ghost Serializer (JSON, Proto, YAML)

Parse and hydrate Kotlin models at up to 1.2 GB/s — drop in beside the serializer you already use.

Ghost sits beside kotlinx.serialization, Jackson, Gson, or Moshi. Annotate only the hot DTOs, leave everything else alone, and migrate when you want.

Kotlin KSP Version Android iOS KMP Wasm Spring Boot Downloads Companies

Quick Start · Maven Central · Live Ghost Speedtest · Playground · Benchmarks · Independent Benchmarks . Coverage · Roadmap


Why teams reach for Ghost

You already have a JSON stack. Ghost is the optimization layer for the endpoints and models that show up in profiles:

  • Byte-first networking — parse ByteArray and Okio streams without String round-trips
  • Low allocation — pooled readers/writers and precomputed field dispatch
  • Incremental adoption — Ghost and your current serializer coexist in the same app
  • Kotlin Multiplatform — Android, iOS, JVM, plus Wasm in this repo
  • Ready adapters — Ktor, Retrofit, Spring MVC / WebFlux
@GhostSerialization
data class User(val id: Long, val name: String, val email: String)

val user: User = Ghost.deserialize(responseBytes)   // hot path
val json: String = Ghost.encodeToString(user)

Your other models keep using KotlinX, Jackson, Gson, or Moshi — unchanged.


Decode at a glance

Twitter macro fixture (631 KB). Three views of the same decode run — throughput ↑, latency ↓, memory ↓:

Twitter macro decode: Ghost vs KSER vs Moshi — throughput GB/s, latency µs/op, memory KB/op for string, bytes, and streaming

Ghost KSER Moshi Ghost vs slowest
Decode string 1.2 GB/s · 514 µs · 361 KB 0.718 GB/s · 879 µs · 1338 KB 0.374 GB/s · 1688 µs · 1709 KB ~3.3× faster · 79% less memory
Decode bytes 1.05 GB/s · 600 µs · 621 KB 0.424 GB/s · 1489 µs · 4297 KB 0.275 GB/s · 2297 µs · 4668 KB ~3.8× faster · 87% less memory
Decode streaming 0.53 GB/s · 1194 µs · 1269 KB 0.193 GB/s · 3270 µs · 1905 KB 0.426 GB/s · 1482 µs · 1709 KB ~2.7× faster · 33% less memory

Full tables + how to run them → Benchmarks · also ktor-ghost on HTTP Arena (+14% vs plain Ktor).

Host: ./gradlew :ghost-benchmark:benchmarkTwitter -PskipTests (full profile, 10 000-iteration warmup) on Ubuntu 24.04 (Linux x86_64) · AMD Ryzen 9 7900X (12 cores / 24 threads, up to ~5.7 GHz boost) · 64 GB RAM · Eclipse Temurin JDK 17 (Gradle jvmToolchain(17)) · Kotlin 2.4.0. Absolute GB/s varies by machine; relative Ghost vs KSER/Moshi rankings are what the regression gate tracks.


Coexist, don't rewrite

Stack How Ghost fits
Ktor ghost() beside json() — Ghost DTOs first, KotlinX for the rest
Retrofit GhostConverterFactory before Gson / Moshi / KotlinX
Spring Boot starter routes @GhostSerialization DTOs; Jackson keeps everything else
Direct calls only the call sites you profile

Step-by-step → Quick Start


Platforms

Targets
Published (Maven Central 1.3.0) Android · iOS · JVM · Wasm (wasmJs)
Toolchain Kotlin 2.4.0 · KSP 2.3.10 · Ktor 3.5.x

Also: Retrofit 2.11+, Spring Boot 3.4+ (MVC + WebFlux), YAML (application/yaml), Proto3 JSON mapping.

Details → Modules


Docs

Guide What you'll find
Quick Start First DTO in minutes
Installation Catalog, KSP, opt-outs
Android & Retrofit Apps, OkHttp, converters
KMP & Ktor Shared module + client/server
iOS & Swift XCFramework bridge
Spring Boot MVC / WebFlux + Jackson
YAML decodeFromYaml, Ktor/Spring/Retrofit adapters
Proto3 JSON WKTs and mapping rules
Advanced Features Resilience, flatten, RawJson
Architecture Prediction, SWAR, hashed dispatch, pools
Roadmap OpenAPI codegen, tests, badges
Contributing Tests and PR checklist

Contributing

git clone https://github.com/juanchurtado1991/ghost-serializer.git
cd ghost-serializer
./gradlew ciTestJvm

License

Apache 2.0

Releases

Packages

Contributors

Languages