Kotlin serializer for TOON (Token-Oriented Object Notation).
To learn about the TOON format and why you should use it read the official website:
- https://toonformat.dev/
- TOON specification: https://github.com/toon-format/spec.
- Full TOON 3.0.1 Spec Support - Complete implementation of the TOON format specification, including tabular arrays, key folding, and delimeters. 400+ tests.
- Kotlin Multiplatform - Supports JVM and JavaScript targets. Others can be added on request.
- Maven Central - Published to Maven Central for easy dependency management with Gradle and Maven.
- Fully Featured
- Encode Kotlin data classes to TOON
- Encode JSON to TOON
- Decode TOON to Kotlin data classes
- Minimal Dependencies - Only depends on kotlinx.serialization, no additional runtime dependencies.
- High Performance - CharArray-based encoding optimized for minimal allocations and fast string operations.
- Flexible Configuration - Configurable delimiters, indentation, and key folding.
Using the Gradle Kotlin DSL:
// build.gradle.kts
dependencies {
implementation("com.lukelast.ktoon:ktoon:VERSION")
}Using Gradle Version Catalog:
# gradle/libs.versions.toml
[versions]
ktoon = "VERSION"
[libraries]
ktoon = { module = "com.lukelast.ktoon:ktoon", version.ref = "ktoon" }// build.gradle.kts
dependencies {
implementation(libs.ktoon)
}For multiplatform projects:
// build.gradle.kts
kotlin {
sourceSets {
commonMain.dependencies {
implementation("com.lukelast.ktoon:ktoon:VERSION")
}
}
}Using Maven:
<!-- pom.xml -->
<dependency>
<groupId>com.lukelast.ktoon</groupId>
<artifactId>ktoon-jvm</artifactId>
<version>VERSION</version>
</dependency>import com.lukelast.ktoon.Ktoon
import kotlinx.serialization.Serializable
@Serializable
data class User(val id: Int, val name: String)
fun main() {
val encoded = Ktoon.Default.encodeToString(User(1, "Alice"))
println(encoded)
}- This library is built to target Java 17.
- You need kotlinx serialization which requires a build plugin.
Check out the demo project in the demo directory for more examples on how to use Ktoon.
demo/README.md)
See the development guide for how to do development.