
High-performance, zero-reflection JSON serializer generating optimized zero-copy byte serializers via compile-time code generation; thread-safe registry, null-safety and memory/DoS safeguards, prewarm.
A high-performance, zero-reflection, multi-platform JSON Serialization Engine for Kotlin.
Ghost Serialization is a next-generation serialization library designed for extreme performance and absolute stability. Built from the ground up to replace legacy reflection-based engines, Ghost uses compile-time KSP (Kotlin Symbol Processing) and the Kotlin 2.1.10 K2 Compiler to generate highly optimized, zero-copy byte serializers.
It natively supports all Kotlin multiplatform targets (Android, iOS, JVM, and WASM-JS) and includes battle-hardened features meant for production environments such as implicit default values, null-safety guards, and direct Ktor 3.0/Retrofit integration.
For a detailed cross-platform analysis and performance transparency report, see GHOST_TRANSPARENCY_REPORT.md.
Ghost parses JSON directly across ByteArray buffers accessing values fundamentally at O(1) complexity.
String object instances entirely.Generates static, deterministic code at compile time.
ServiceLoader and a hashed registry GhostRegistry to locate serializers.@Keep rules needed for internals.The engine has been audited for zero-compromise stability across all platforms (JVM, iOS, Android, JS, Wasm).
Long and Int parsing to prevent silent data corruption.maxCollectionSize (via GhostHeuristics) protects against memory exhaustion (DoS) from malicious payloads.Understand Kotlin's complex type-system natively without boilerplate adapters.
@JvmInline unboxed mapping logic).Add the dependencies to your build.gradle.kts modules.
plugins {
id("com.google.devtools.ksp") version "2.1.10-1.0.30"
}
dependencies {
val ghostVersion = "1.1.7"
// 1. Add the KSP Compiler plugin
add("kspCommonMainMetadata", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspJvm", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspAndroid", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspIosArm64", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspIosSimulatorArm64", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspWasmJs", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspJs", "com.ghostserializer:ghost-compiler:$ghostVersion")
// 2. Add the Ghost Runtime
implementation("com.ghostserializer:ghost-serialization:$ghostVersion")
implementation("com.ghostserializer:ghost-api:$ghostVersion")
// (Optional) For Ktor 3.0 / Ktorfit 2.3.0 Integration
implementation("com.ghostserializer:ghost-ktor:$ghostVersion")
}Simply decorate any Data Class, Sealed Class, Enum, or Value Class with @GhostSerialization.
import com.ghost.serialization.api.GhostSerialization
@GhostSerialization
data class UserProfile(
val id: String,
val alias: String,
val isActive: Boolean = true,
val role: UserRole = UserRole.GUEST
)
@GhostSerialization(fallback = "GUEST")
enum class UserRole {
ADMIN, MODERATOR, GUEST
}import com.ghost.serialization.Ghost
val profile = UserProfile(id = "U-199", alias = "GhostProtocol")
// Serialize to JSON string
val jsonPayload = Ghost.serialize(profile)
// Deserialize back to Domain Object
val restoredProfile = Ghost.deserialize<UserProfile>(jsonPayload)Ghost is a first-class citizen in the KMP networking stack.
val client = HttpClient {
install(ContentNegotiation) {
ghost() // High-performance streaming converter
}
}Ghost provides a Zero-Kotlin workflow for web developers. You can define your models in TypeScript and sync them automatically with the high-performance WASM engine.
npm install ghost-serialization-wasm
ghost-models/ directory in your project root and add your TS interfaces:
export interface User {
id: number;
name: string;
}node node_modules/ghost-serialization-wasm/tools/ghost-transpiler.js
# Then rebuild/sync your local bridgeimport { ghostPrewarm } from "ghost-serialization-wasm";
import { deserializeModel } from "./ghost-generated-types/ghost-bridge";
// Initialize (Automatic model registration)
ghostPrewarm();
// High-performance, fully-typed deserialization
const user = deserializeModel(json, "User"); // 'user' is now typed as User!To achieve absolute zero-latency on the first call, use prewarm().
Ghost.prewarm()The project adheres to strict architectural separation:
ghost-api: High-level annotations and contracts.ghost-serialization: Core parsing and writing engine.ghost-compiler: Single-pass KSP generator.ghost-ktor: Official Ktor 3.0 integration.Maintained under Ghost Protocol Principles. Version 1.1.7 Stable.
A high-performance, zero-reflection, multi-platform JSON Serialization Engine for Kotlin.
Ghost Serialization is a next-generation serialization library designed for extreme performance and absolute stability. Built from the ground up to replace legacy reflection-based engines, Ghost uses compile-time KSP (Kotlin Symbol Processing) and the Kotlin 2.1.10 K2 Compiler to generate highly optimized, zero-copy byte serializers.
It natively supports all Kotlin multiplatform targets (Android, iOS, JVM, and WASM-JS) and includes battle-hardened features meant for production environments such as implicit default values, null-safety guards, and direct Ktor 3.0/Retrofit integration.
For a detailed cross-platform analysis and performance transparency report, see GHOST_TRANSPARENCY_REPORT.md.
Ghost parses JSON directly across ByteArray buffers accessing values fundamentally at O(1) complexity.
String object instances entirely.Generates static, deterministic code at compile time.
ServiceLoader and a hashed registry GhostRegistry to locate serializers.@Keep rules needed for internals.The engine has been audited for zero-compromise stability across all platforms (JVM, iOS, Android, JS, Wasm).
Long and Int parsing to prevent silent data corruption.maxCollectionSize (via GhostHeuristics) protects against memory exhaustion (DoS) from malicious payloads.Understand Kotlin's complex type-system natively without boilerplate adapters.
@JvmInline unboxed mapping logic).Add the dependencies to your build.gradle.kts modules.
plugins {
id("com.google.devtools.ksp") version "2.1.10-1.0.30"
}
dependencies {
val ghostVersion = "1.1.7"
// 1. Add the KSP Compiler plugin
add("kspCommonMainMetadata", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspJvm", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspAndroid", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspIosArm64", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspIosSimulatorArm64", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspWasmJs", "com.ghostserializer:ghost-compiler:$ghostVersion")
add("kspJs", "com.ghostserializer:ghost-compiler:$ghostVersion")
// 2. Add the Ghost Runtime
implementation("com.ghostserializer:ghost-serialization:$ghostVersion")
implementation("com.ghostserializer:ghost-api:$ghostVersion")
// (Optional) For Ktor 3.0 / Ktorfit 2.3.0 Integration
implementation("com.ghostserializer:ghost-ktor:$ghostVersion")
}Simply decorate any Data Class, Sealed Class, Enum, or Value Class with @GhostSerialization.
import com.ghost.serialization.api.GhostSerialization
@GhostSerialization
data class UserProfile(
val id: String,
val alias: String,
val isActive: Boolean = true,
val role: UserRole = UserRole.GUEST
)
@GhostSerialization(fallback = "GUEST")
enum class UserRole {
ADMIN, MODERATOR, GUEST
}import com.ghost.serialization.Ghost
val profile = UserProfile(id = "U-199", alias = "GhostProtocol")
// Serialize to JSON string
val jsonPayload = Ghost.serialize(profile)
// Deserialize back to Domain Object
val restoredProfile = Ghost.deserialize<UserProfile>(jsonPayload)Ghost is a first-class citizen in the KMP networking stack.
val client = HttpClient {
install(ContentNegotiation) {
ghost() // High-performance streaming converter
}
}Ghost provides a Zero-Kotlin workflow for web developers. You can define your models in TypeScript and sync them automatically with the high-performance WASM engine.
npm install ghost-serialization-wasm
ghost-models/ directory in your project root and add your TS interfaces:
export interface User {
id: number;
name: string;
}node node_modules/ghost-serialization-wasm/tools/ghost-transpiler.js
# Then rebuild/sync your local bridgeimport { ghostPrewarm } from "ghost-serialization-wasm";
import { deserializeModel } from "./ghost-generated-types/ghost-bridge";
// Initialize (Automatic model registration)
ghostPrewarm();
// High-performance, fully-typed deserialization
const user = deserializeModel(json, "User"); // 'user' is now typed as User!To achieve absolute zero-latency on the first call, use prewarm().
Ghost.prewarm()The project adheres to strict architectural separation:
ghost-api: High-level annotations and contracts.ghost-serialization: Core parsing and writing engine.ghost-compiler: Single-pass KSP generator.ghost-ktor: Official Ktor 3.0 integration.Maintained under Ghost Protocol Principles. Version 1.1.7 Stable.